Whitespace after textarea/pre patch
authorMicky Hulse <mickyhulse@gmail.com>
Tue, 20 Aug 2013 06:32:20 +0000 (23:32 -0700)
committerMicky Hulse <mickyhulse@gmail.com>
Tue, 20 Aug 2013 06:32:20 +0000 (23:32 -0700)
Fix for issue #77 with collapseWhitespace tests.

dist/all.js
src/htmlminifier.js
tests/minifier.js

index c702659..5333f9a 100644 (file)
           }
         }
         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);
           }
         }
index bf38f30..acde7dc 100644 (file)
           }
         }
         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);
           }
         }
index 3342c42..8013f55 100644 (file)
     output = '<!--[if IE 7]>'+
                 '<link rel="stylesheet" href="/css/ie7-fixes.css" type="text/css" />'+
              '<![endif]-->'
-
     equal(minify(input, { removeComments: true }), output);
 
-
     input = '<!--[if lte IE 6]>\n    \n   \n\n\n\t' +
               '<p title=" sigificant     whitespace   ">blah blah</p>' +
             '<![endif]-->';
     output = '<!--[if lte IE 6]>' +
               '<p title=" sigificant     whitespace   ">blah blah</p>' +
             '<![endif]-->';
-
     equal(minify(input, { removeComments: true }), output);
   });
 
     output = '<div><textarea></textarea></div>';
     equal(minify(input, { collapseWhitespace: true }), output);
 
+    input = '<div><pre> $foo = "baz"; </pre>    </div>';
+    output = '<div><pre> $foo = "baz"; </pre></div>';
+    equal(minify(input, { collapseWhitespace: true }), output);
+
+     input = '<script type=\"text\/javascript\">var = \"hello\";<\/script>\r\n\r\n\r\n'              +
+             '<style type=\"text\/css\">#foo { color: red;        }          <\/style>\r\n\r\n\r\n'  +
+             '<div>\r\n  <div>\r\n    <div><!-- hello -->\r\n      <div>'                            +
+             '<!--! hello -->\r\n        <div>\r\n          <div class=\"\">\r\n\r\n            '    +
+             '<textarea disabled=\"disabled\">     this is a textarea <\/textarea>\r\n          '    +
+             '<\/div>\r\n        <\/div>\r\n      <\/div>\r\n    <\/div>\r\n  <\/div>\r\n<\/div>'    +
+             '<pre>       \r\nxxxx<\/pre><span>x<\/span> <span>Hello<\/span> <b>billy<\/b>     \r\n' +
+             '<input type=\"text\">\r\n<textarea><\/textarea>\r\n<pre><\/pre>';
+    output = '<script type="text/javascript">var = "hello";</script>'                                +
+             '<style type="text/css">#foo { color: red;        }</style>'                            +
+             '<div><div><div>'                                                                       +
+             '<!-- hello --><div><!--! hello --><div><div class="">'                                 +
+             '<textarea disabled="disabled">     this is a textarea </textarea>'                     +
+             '</div></div></div></div></div></div>'                                                  +
+             '<pre>       \r\nxxxx</pre><span>x</span> <span>Hello</span> <b>billy</b>'              +
+             '<input type="text"><textarea></textarea><pre></pre>';
+    equal(minify(input, { collapseWhitespace: true }), output);
+
     input = '<pre title="some title...">   hello     world </pre>';
     output = '<pre title="some title...">   hello     world </pre>';
     equal(minify(input, { collapseWhitespace: true }), output);