removeComments affects htmlmin:ignore comments
authorDuncan Beevers <duncan@dweebd.com>
Wed, 20 Aug 2014 20:39:08 +0000 (15:39 -0500)
committerDuncan Beevers <duncan@dweebd.com>
Wed, 20 Aug 2014 20:39:08 +0000 (15:39 -0500)
src/htmlminifier.js
tests/minifier.js

index 6d07307..4833dcf 100644 (file)
 
         if (/^\s*htmlmin:ignore/.test(text)) {
           isIgnoring = !isIgnoring;
-          buffer.push('<!--' + text + '-->');
+          if (!options.removeComments) {
+            buffer.push('<!--' + text + '-->');
+          }
           return;
         }
         if (options.removeComments) {
index 7fba30c..77668b6 100644 (file)
     output = '<!-- htmlmin:ignore --><div class="blah" style="color: red">\n   test   <span> <input disabled/>  foo </span>\n\n   </div><!-- htmlmin:ignore -->' +
             '<div class="blah" style="color: red">test <span><input disabled="disabled"> foo</span></div>';
 
-    equal(minify(input, { collapseWhitespace: true }), output);
+    equal(minify(input, { collapseWhitespace: true, removeComments: false }), output);
+
+    output = '<div class="blah" style="color: red">\n   test   <span> <input disabled/>  foo </span>\n\n   </div>' +
+            '<div class="blah" style="color: red">test <span><input disabled="disabled"> foo</span></div>';
+
+    equal(minify(input, { collapseWhitespace: true, removeComments: true }), output);
+
+    input = '<!-- htmlmin:ignore --><!-- htmlmin:ignore -->';
+    equal(minify(input, { removeComments: true }), '');
+    equal(minify(input, { removeComments: false }), input);
   });
 
   test('meta viewport', function() {