From: Juriy Zaytsev Date: Mon, 8 Feb 2010 23:57:34 +0000 (-0500) Subject: Collapse whitespace in class attributes to 1 space (not only trim). X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6256d94b8f404e9e4b0d4fd026500b63a8ab1afe;p=html-minifier.git Collapse whitespace in class attributes to 1 space (not only trim). --- 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);