From: Micky Hulse Date: Tue, 20 Aug 2013 06:32:20 +0000 (-0700) Subject: Whitespace after textarea/pre patch X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a590fbe6f6324cf93536630a23f35ac66d1ddaf9;p=html-minifier.git Whitespace after textarea/pre patch Fix for issue #77 with collapseWhitespace tests. --- diff --git a/dist/all.js b/dist/all.js index c702659..5333f9a 100644 --- a/dist/all.js +++ b/dist/all.js @@ -731,10 +731,10 @@ } } if (options.collapseWhitespace) { - if (!stackNoTrimWhitespace.length && _canTrimWhitespace(currentTag, currentAttrs)) { + if (!stackNoTrimWhitespace.length) { text = (prevTag || nextTag) ? collapseWhitespaceSmart(text, prevTag, nextTag) : trimWhitespace(text); } - if (!stackNoCollapseWhitespace.length && _canCollapseWhitespace(currentTag, currentAttrs)) { + if (!stackNoCollapseWhitespace.length) { text = collapseWhitespace(text); } } diff --git a/src/htmlminifier.js b/src/htmlminifier.js index bf38f30..acde7dc 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -387,10 +387,10 @@ } } if (options.collapseWhitespace) { - if (!stackNoTrimWhitespace.length && _canTrimWhitespace(currentTag, currentAttrs)) { + if (!stackNoTrimWhitespace.length) { text = (prevTag || nextTag) ? collapseWhitespaceSmart(text, prevTag, nextTag) : trimWhitespace(text); } - if (!stackNoCollapseWhitespace.length && _canCollapseWhitespace(currentTag, currentAttrs)) { + if (!stackNoCollapseWhitespace.length) { text = collapseWhitespace(text); } } diff --git a/tests/minifier.js b/tests/minifier.js index 3342c42..8013f55 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -168,17 +168,14 @@ output = '' - equal(minify(input, { removeComments: true }), output); - input = ''; output = ''; - equal(minify(input, { removeComments: true }), output); }); @@ -517,6 +514,28 @@ output = '
'; equal(minify(input, { collapseWhitespace: true }), output); + input = '
 $foo = "baz"; 
'; + output = '
 $foo = "baz"; 
'; + equal(minify(input, { collapseWhitespace: true }), output); + + input = '' + + '' + + '
' + + '
' + + '' + + '
' + + '
       \r\nxxxx
x Hello billy' + + '
';
+    equal(minify(input, { collapseWhitespace: true }), output);
+
     input = '
   hello     world 
'; output = '
   hello     world 
'; equal(minify(input, { collapseWhitespace: true }), output);