From: Juriy Zaytsev Date: Mon, 15 Mar 2010 17:46:39 +0000 (-0400) Subject: Strip trailing ";" from style attributes (this allows to strip quotes from values... X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=60addbb1bdf83eb851d8c4ec7cb65722ddc7cabd;p=html-minifier.git Strip trailing ";" from style attributes (this allows to strip quotes from values like "display:none;"). --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index fd7d940..e42e2db 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -123,11 +123,12 @@ else if (attrName === 'class') { return collapseWhitespace(trimWhitespace(attrValue)); } - else if (isUriTypeAttribute(attrName, tag) - || isNumberTypeAttribute(attrName, tag) - || attrName === 'style') { + else if (isUriTypeAttribute(attrName, tag) || isNumberTypeAttribute(attrName, tag)) { return trimWhitespace(attrValue); } + else if (attrName === 'style') { + return trimWhitespace(attrValue).replace(/\s*;\s*$/, ''); + } return attrValue; } diff --git a/tests/index.html b/tests/index.html index fab005b..bec13dc 100644 --- a/tests/index.html +++ b/tests/index.html @@ -220,7 +220,11 @@ equals(minify(input, { cleanAttributes: true }), output); input = '

'; - output = '

'; + output = '

'; + equals(minify(input, { cleanAttributes: true }), output); + + input = '

'; + output = '

'; equals(minify(input, { cleanAttributes: true }), output); });