use lower case in `useShortDoctype` (#944)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 8 Jul 2018 18:05:00 +0000 (02:05 +0800)
committerGitHub <noreply@github.com>
Sun, 8 Jul 2018 18:05:00 +0000 (02:05 +0800)
fixes #822

src/htmlminifier.js
tests/minifier.js

index f21f8d3..2285032 100644 (file)
@@ -1220,7 +1220,7 @@ function minify(value, options, partialMarkup) {
       buffer.push(text);
     },
     doctype: function(doctype) {
-      buffer.push(options.useShortDoctype ? '<!DOCTYPE html>' : collapseWhitespaceAll(doctype));
+      buffer.push(options.useShortDoctype ? '<!doctype html>' : collapseWhitespaceAll(doctype));
     },
     customAttrAssign: options.customAttrAssign,
     customAttrSurround: options.customAttrSurround
index a3cf039..bb59cda 100644 (file)
@@ -404,22 +404,23 @@ QUnit.test('types of whitespace that should always be preserved', function(asser
 
 QUnit.test('doctype normalization', function(assert) {
   var input;
+  var output = '<!doctype html>';
 
   input = '<!DOCTYPE html>';
   assert.equal(minify(input, { useShortDoctype: false }), input);
-  assert.equal(minify(input, { useShortDoctype: true }), input);
+  assert.equal(minify(input, { useShortDoctype: true }), output);
 
   input = '<!DOCTYPE\nhtml>';
   assert.equal(minify(input, { useShortDoctype: false }), '<!DOCTYPE html>');
-  assert.equal(minify(input, { useShortDoctype: true }), '<!DOCTYPE html>');
+  assert.equal(minify(input, { useShortDoctype: true }), output);
 
   input = '<!DOCTYPE\thtml>';
   assert.equal(minify(input, { useShortDoctype: false }), input);
-  assert.equal(minify(input, { useShortDoctype: true }), '<!DOCTYPE html>');
+  assert.equal(minify(input, { useShortDoctype: true }), output);
 
   input = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n    "http://www.w3.org/TR/html4/strict.dtd">';
   assert.equal(minify(input, { useShortDoctype: false }), '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
-  assert.equal(minify(input, { useShortDoctype: true }), '<!DOCTYPE html>');
+  assert.equal(minify(input, { useShortDoctype: true }), output);
 });
 
 QUnit.test('removing comments', function(assert) {