Skip to content

Commit

Permalink
Merge pull request #970 from mathiasbynens/doctype
Browse files Browse the repository at this point in the history
Use <!doctypehtml> (without the space) where possible
  • Loading branch information
kangax committed Oct 23, 2018
2 parents cf55c51 + 7e8406e commit f625991
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/htmlminifier.js
Expand Up @@ -1238,7 +1238,9 @@ function minify(value, options, partialMarkup) {
buffer.push(text);
},
doctype: function(doctype) {
buffer.push(options.useShortDoctype ? '<!doctype html>' : collapseWhitespaceAll(doctype));
buffer.push(options.useShortDoctype ? '<!doctype' +
(options.removeTagWhitespace ? '' : ' ') + 'html>' :
collapseWhitespaceAll(doctype));
},
customAttrAssign: options.customAttrAssign,
customAttrSurround: options.customAttrSurround
Expand Down
5 changes: 5 additions & 0 deletions tests/minifier.js
Expand Up @@ -410,6 +410,11 @@ QUnit.test('doctype normalization', function(assert) {
assert.equal(minify(input, { useShortDoctype: false }), input);
assert.equal(minify(input, { useShortDoctype: true }), output);

assert.equal(minify(input, {
useShortDoctype: true,
removeTagWhitespace: true
}), '<!doctypehtml>');

input = '<!DOCTYPE\nhtml>';
assert.equal(minify(input, { useShortDoctype: false }), '<!DOCTYPE html>');
assert.equal(minify(input, { useShortDoctype: true }), output);
Expand Down

0 comments on commit f625991

Please sign in to comment.