From 515f57cc47b861ffedf5846b96efa4896db8f581 Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Thu, 4 Mar 2010 18:21:54 -0500 Subject: [PATCH] Add TR to the list of optional end tags. --- index.html | 10 +++++++++- src/htmlminifier.js | 2 +- tests/index.html | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 23fcc29c..d1ef19a7 100644 --- a/index.html +++ b/index.html @@ -100,7 +100,15 @@

HTML Minifier (ver. 0.3)

Remove optional tags
- Currently, only </html>, </head>, and </body> + Currently, only: + </html>, + </head>, + </body>, + </thead>, + </tbody>, + </tfoot>, + and + </tr> diff --git a/src/htmlminifier.js b/src/htmlminifier.js index d1c0f7b9..0ac01c55 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -126,7 +126,7 @@ } 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) { diff --git a/tests/index.html b/tests/index.html index 9cf97ebc..c7f12c46 100644 --- a/tests/index.html +++ b/tests/index.html @@ -353,9 +353,22 @@

output = 'hello

foobar

'; equals(minify(input, { removeOptionalTags: true }), output); equals(minify(input), input); - - input = '
'; - output = '
'; + }); + + test('removing optional tags in tables', function(){ + + input = ''+ + ''+ + ''+ + ''+ + '
foobar
bazqux
boomoo
'; + + output = ''+ + ''+ + ''+ + ''+ + '
foobar
bazqux
boomoo
'; + equals(minify(input, { removeOptionalTags: true }), output); equals(minify(input), input); });