From 54e6ebc3b4b97f63d18e4ee33abcc1b6a3045cdf Mon Sep 17 00:00:00 2001 From: Duncan Beevers Date: Sat, 26 Jul 2014 18:14:16 -0500 Subject: [PATCH] Emit custom attr assign --- src/htmlminifier.js | 3 ++- src/htmlparser.js | 1 + tests/minifier.js | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/htmlminifier.js b/src/htmlminifier.js index a59176d..ffd0ce5 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -334,7 +334,7 @@ attrFragment = attrName; } else { - attrFragment = attrName + '=' + attrValue; + attrFragment = attrName + attr.customAssign + attrValue; } return (' ' + attr.customOpen + attrFragment + attr.customClose); @@ -611,6 +611,7 @@ doctype: function(doctype) { buffer.push(options.useShortDoctype ? '' : collapseWhitespace(doctype)); }, + customAttrAssign: options.customAttrAssign, customAttrSurround: options.customAttrSurround }); diff --git a/src/htmlparser.js b/src/htmlparser.js index ef0053b..c7dbee5 100644 --- a/src/htmlparser.js +++ b/src/htmlparser.js @@ -345,6 +345,7 @@ name: name, value: value, escaped: value && value.replace(/(^|[^\\])"/g, '$1"'), + customAssign: customAssign || '=', customOpen: customOpen || '', customClose: customClose || '' }); diff --git a/tests/minifier.js b/tests/minifier.js index 314c6fe..dcadb07 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -555,6 +555,21 @@ equal(minify(input, customAttrOptions), ''); }); + test('preserving custom attribute-joining markup', function() { + var polymerConditionalAttributeJoin = /\?=/; + var customAttrOptions = { + customAttrAssign: [ polymerConditionalAttributeJoin ] + }; + + input = '
'; + + equal(minify(input, customAttrOptions), input); + + input = '
'; + + equal(minify(input, customAttrOptions), input); + }); + test('collapsing whitespace', function() { input = '