Handle custom attributes with empty values, fixes #270
authorDennis Saenger <dsaenger@rea.de>
Fri, 19 Sep 2014 07:49:26 +0000 (09:49 +0200)
committerDennis Saenger <dsaenger@rea.de>
Mon, 22 Sep 2014 10:26:06 +0000 (12:26 +0200)
src/htmlminifier.js
tests/minifier.js

index d5f4b00..b2c5108 100644 (file)
     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;
index ea6b0d7..dbce105 100644 (file)
     equal(minify(input, { customAttrCollapse: /ng\-class/ }), output);
   });
 
+  test('custom attribute collapse with empty attribute value', function() {
+    input = '<div ng-some\n\n></div>';
+    output = '<div ng-some></div>';
+
+    equal(minify( input, { customAttrCollapse: /.+/ }), output);
+  });
+
 })(typeof exports === 'undefined' ? window : exports);