From 60addbb1bdf83eb851d8c4ec7cb65722ddc7cabd Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Mon, 15 Mar 2010 13:46:39 -0400 Subject: [PATCH] Strip trailing ";" from style attributes (this allows to strip quotes from values like "display:none;"). --- src/htmlminifier.js | 7 ++++--- tests/index.html | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) 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); }); -- 2.34.1