Remove optional tags
<br>
<span class="quiet short">
- Currently, only <code></html></code>, <code></head></code>, and <code></body></code>
+ Currently, only:
+ <code></html></code>,
+ <code></head></code>,
+ <code></body></code>,
+ <code></thead></code>,
+ <code></tbody></code>,
+ <code></tfoot></code>,
+ and
+ <code></tr></code>
</span>
</label>
</li>
}
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) {
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);
});