Add TR to the list of optional end tags.
authorJuriy Zaytsev <kangax@gmail.com>
Thu, 4 Mar 2010 23:21:54 +0000 (18:21 -0500)
committerJuriy Zaytsev <kangax@gmail.com>
Thu, 4 Mar 2010 23:21:54 +0000 (18:21 -0500)
index.html
src/htmlminifier.js
tests/index.html

index 23fcc29..d1ef19a 100644 (file)
                 Remove optional tags
                 <br>
                 <span class="quiet short">
-                  Currently, only <code>&lt;/html></code>, <code>&lt;/head></code>, and <code>&lt;/body></code>
+                  Currently, only: 
+                  <code>&lt;/html></code>, 
+                  <code>&lt;/head></code>, 
+                  <code>&lt;/body></code>, 
+                  <code>&lt;/thead></code>,
+                  <code>&lt;/tbody></code>,
+                  <code>&lt;/tfoot></code>,
+                  and
+                  <code>&lt;/tr></code>
                 </span>
               </label>
             </li>
index d1c0f7b..0ac01c5 100644 (file)
   }
   
   function isOptionalTag(tag) {
-    return (/^(?:html|t?body|t?head|tfoot)$/).test(tag);
+    return (/^(?:html|t?body|t?head|tfoot|tr)$/).test(tag);
   }
   
   function canCollapseWhitespace(tag) {
index 9cf97eb..c7f12c4 100644 (file)
           output = '<html><head><title>hello</title><body><p>foo<span>bar</span></p>';
           equals(minify(input, { removeOptionalTags: true }), output);
           equals(minify(input), input);
-          
-          input = '<table><thead><tr></tr></thead><tfoot><tr></tr></tfoot><tbody><tr></tr></tbody></table>';
-          output = '<table><thead><tr></tr><tfoot><tr></tr><tbody><tr></tr></table>';
+        });
+        
+        test('removing optional tags in tables', function(){
+          
+          input = '<table>'+
+                    '<thead><tr><th>foo</th><th>bar</th></tr></thead>'+
+                    '<tfoot><tr><th>baz</th><th>qux</th></tr></tfoot>'+
+                    '<tbody><tr><td>boo</td><td>moo</td></tr></tbody>'+
+                  '</table>';
+                  
+          output = '<table>'+
+                    '<thead><tr><th>foo</th><th>bar</th>'+
+                    '<tfoot><tr><th>baz</th><th>qux</th>'+
+                    '<tbody><tr><td>boo</td><td>moo</td>'+
+                   '</table>';
+                    
           equals(minify(input, { removeOptionalTags: true }), output);
           equals(minify(input), input);
         });