From: Duncan Beevers Date: Wed, 20 Aug 2014 20:39:08 +0000 (-0500) Subject: removeComments affects htmlmin:ignore comments X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4254fab489580b97972451175a5a02526d7c8109;p=html-minifier.git removeComments affects htmlmin:ignore comments --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 6d07307..4833dcf 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -623,7 +623,9 @@ if (/^\s*htmlmin:ignore/.test(text)) { isIgnoring = !isIgnoring; - buffer.push(''); + if (!options.removeComments) { + buffer.push(''); + } return; } if (options.removeComments) { diff --git a/tests/minifier.js b/tests/minifier.js index 7fba30c..77668b6 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -993,7 +993,16 @@ output = '
\n test foo \n\n
' + '
test foo
'; - equal(minify(input, { collapseWhitespace: true }), output); + equal(minify(input, { collapseWhitespace: true, removeComments: false }), output); + + output = '
\n test foo \n\n
' + + '
test foo
'; + + equal(minify(input, { collapseWhitespace: true, removeComments: true }), output); + + input = ''; + equal(minify(input, { removeComments: true }), ''); + equal(minify(input, { removeComments: false }), input); }); test('meta viewport', function() {