From 6256d94b8f404e9e4b0d4fd026500b63a8ab1afe Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Mon, 8 Feb 2010 18:57:34 -0500 Subject: [PATCH] Collapse whitespace in class attributes to 1 space (not only trim). --- src/htmlminifier.js | 3 ++- tests/index.html | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 4615877..6a4bda9 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -66,7 +66,8 @@ return attrValue.replace(/^(['"])?javascript:/i, '$1'); } if (attrName.toLowerCase() === 'class') { - return attrValue.replace(/^(["'])?\s+/, '$1').replace(/\s+(["'])?$/, '$1'); + // trim and collapse whitesapce + return attrValue.replace(/^(["'])?\s+/, '$1').replace(/\s+(["'])?$/, '$1').replace(/\s+/g, ' '); } return attrValue; } diff --git a/tests/index.html b/tests/index.html index 5d2620e..1e75ad9 100644 --- a/tests/index.html +++ b/tests/index.html @@ -95,6 +95,9 @@ input = '

foo bar baz

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

foo bar baz

'); + + input = '

foo bar baz

'; + equals(minify(input, { shouldCleanAttributes: true }), '

foo bar baz

'); }); })(this); -- 2.34.1