Emit custom attr assign
authorDuncan Beevers <duncan@dweebd.com>
Sat, 26 Jul 2014 23:14:16 +0000 (18:14 -0500)
committerDuncan Beevers <duncan@dweebd.com>
Sat, 26 Jul 2014 23:14:19 +0000 (18:14 -0500)
src/htmlminifier.js
src/htmlparser.js
tests/minifier.js

index a59176d..ffd0ce5 100644 (file)
       attrFragment = attrName;
     }
     else {
-      attrFragment = attrName + '=' + attrValue;
+      attrFragment = attrName + attr.customAssign + attrValue;
     }
 
     return (' ' + attr.customOpen + attrFragment + attr.customClose);
       doctype: function(doctype) {
         buffer.push(options.useShortDoctype ? '<!DOCTYPE html>' : collapseWhitespace(doctype));
       },
+      customAttrAssign: options.customAttrAssign,
       customAttrSurround: options.customAttrSurround
     });
 
index ef0053b..c7dbee5 100644 (file)
             name: name,
             value: value,
             escaped: value && value.replace(/(^|[^\\])"/g, '$1&quot;'),
+            customAssign: customAssign || '=',
             customOpen:  customOpen || '',
             customClose: customClose || ''
           });
index 314c6fe..dcadb07 100644 (file)
     equal(minify(input, customAttrOptions), '<input {{#if value1}}checked{{/if}} {{#if value2}}data-attr=foo{{/if}}>');
   });
 
+  test('preserving custom attribute-joining markup', function() {
+    var polymerConditionalAttributeJoin = /\?=/;
+    var customAttrOptions = {
+      customAttrAssign: [ polymerConditionalAttributeJoin ]
+    };
+
+    input = '<div flex?="{{mode != cover}}"></div>';
+
+    equal(minify(input, customAttrOptions), input);
+
+    input = '<div flex?="{{mode != cover}}" class="foo"></div>';
+
+    equal(minify(input, customAttrOptions), input);
+  });
+
   test('collapsing whitespace', function() {
     input = '<script type="text/javascript">  \n\t   alert(1) \n\n\n  \t <\/script>';
     output = '<script type="text/javascript">alert(1)<\/script>';