From: Dennis Saenger Date: Fri, 19 Sep 2014 07:49:26 +0000 (+0200) Subject: Handle custom attributes with empty values, fixes #270 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a366df7406be2c6080c58b81ee993181a8ecbd89;p=html-minifier.git Handle custom attributes with empty values, fixes #270 --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index d5f4b00..b2c5108 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -249,7 +249,7 @@ else if (isMetaViewport(tag, attrs) && attrName === 'content') { attrValue = attrValue.replace(/1\.0/g, '1').replace(/\s+/g, ''); } - else if (options.customAttrCollapse && options.customAttrCollapse.test(attrName)) { + else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) { attrValue = attrValue.replace(/\n+/g, ''); } return attrValue; diff --git a/tests/minifier.js b/tests/minifier.js index ea6b0d7..dbce105 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -1195,4 +1195,11 @@ equal(minify(input, { customAttrCollapse: /ng\-class/ }), output); }); + test('custom attribute collapse with empty attribute value', function() { + input = '
'; + output = '
'; + + equal(minify( input, { customAttrCollapse: /.+/ }), output); + }); + })(typeof exports === 'undefined' ? window : exports);