}
function isConditionalComment(text) {
- return /^\[if\s[^\]]+\]|\[endif\]$/.test(text);
+ return /^\[if\s[^\]]+]|\[endif]$/.test(text);
}
function isIgnoredComment(text, options) {
}
function cleanConditionalComment(comment, options) {
- return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)(<!\[endif\])$/, function(match, prefix, text, suffix) {
+ return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+]>)([\s\S]*?)(<!\[endif])$/, function(match, prefix, text, suffix) {
return prefix + minify(text, options, true) + suffix;
}) : comment;
}
}
// Regular Expressions for parsing tags and attributes
-var singleAttrIdentifier = /([^\s"'<>\/=]+)/,
+var singleAttrIdentifier = /([^\s"'<>/=]+)/,
singleAttrAssign = /=/,
singleAttrAssigns = [singleAttrAssign],
singleAttrValues = [
if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
text = text
.replace(/<!--([\s\S]*?)-->/g, '$1')
- .replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
+ .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
}
if (handler.chars) {
// https://github.com/kangax/html-minifier/issues/10
QUnit.test('Ignore custom fragments', function(assert) {
var input, output;
- var reFragments = [/<\?[^\?]+\?>/, /<%[^%]+%>/, /\{\{[^\}]*\}\}/];
+ var reFragments = [/<\?[^?]+\?>/, /<%[^%]+%>/, /\{\{[^}]*\}\}/];
input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n<? ... ?>\r\n<!-- This is the middle, and a comment. -->\r\nNo comment, but middle.\r\n{{ ... }}\r\n<?php ... ?>\r\n<?xml ... ?>\r\nHello, this is the end!';
output = 'This is the start. <% ... %> <%= ... %> <? ... ?> No comment, but middle. {{ ... }} <?php ... ?> <?xml ... ?> Hello, this is the end!';
output = '<div data-bind="css: {fadeIn: selected(),fadeOut: !selected()},visible: function () {return pageWeAreOn() == \'home\';}">foo</div>';
assert.equal(minify(input), input);
- assert.equal(minify(input, { customAttrCollapse: /data\-bind/ }), output);
+ assert.equal(minify(input, { customAttrCollapse: /data-bind/ }), output);
input = '<div style="' +
'color: red;' +
'> ' +
'</div>';
output = '<div class="fragment square" ng-hide="square1.hide" ng-class="{\'bounceInDown\': !square1.hide, \'bounceOutDown\': square1.hide }"> </div>';
- assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output);
+ assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output);
});
QUnit.test('custom attribute collapse with empty attribute value', function(assert) {
' value2:false \n\r' +
' }"></div>';
var output = '<div ng-class="{value:true,value2:false}"></div>';
- assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output);
+ assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output);
});
QUnit.test('do not escape attribute value', function(assert) {