minifier.js (html-minifier-3.6.0) | : | minifier.js (html-minifier-4.0.0) | ||
---|---|---|---|---|
skipping to change at line 67 | skipping to change at line 67 | |||
input = '<html ⚡></html>'; | input = '<html ⚡></html>'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
input = '<h:ællæ></h:ællæ>'; | input = '<h:ællæ></h:ællæ>'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
input = '<$unicorn>'; | input = '<$unicorn>'; | |||
assert.throws(function() { | assert.throws(function() { | |||
minify(input); | minify(input); | |||
}, 'Invalid tag name'); | }, 'Invalid tag name'); | |||
assert.equal(minify(input, { | ||||
continueOnParseError: true, | ||||
}), input); | ||||
input = '<begriffs.pagination ng-init="perPage=20" collection="logs" url="\'/a pi/logs?user=-1\'" per-page="perPage" per-page-presets="[10,20,50,100]" template -url="/assets/paginate-anything.html"></begriffs.pagination>'; | input = '<begriffs.pagination ng-init="perPage=20" collection="logs" url="\'/a pi/logs?user=-1\'" per-page="perPage" per-page-presets="[10,20,50,100]" template -url="/assets/paginate-anything.html"></begriffs.pagination>'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
// https://github.com/kangax/html-minifier/issues/41 | // https://github.com/kangax/html-minifier/issues/41 | |||
assert.equal(minify('<some-tag-1></some-tag-1><some-tag-2></some-tag-2>'), | assert.equal(minify('<some-tag-1></some-tag-1><some-tag-2></some-tag-2>'), | |||
'<some-tag-1></some-tag-1><some-tag-2></some-tag-2>' | '<some-tag-1></some-tag-1><some-tag-2></some-tag-2>' | |||
); | ); | |||
// https://github.com/kangax/html-minifier/issues/40 | // https://github.com/kangax/html-minifier/issues/40 | |||
skipping to change at line 96 | skipping to change at line 99 | |||
assert.equal(minify('<a href>ok</a>'), '<a href>ok</a>'); | assert.equal(minify('<a href>ok</a>'), '<a href>ok</a>'); | |||
assert.equal(minify('<a onclick></a>'), '<a onclick></a>'); | assert.equal(minify('<a onclick></a>'), '<a onclick></a>'); | |||
// https://github.com/kangax/html-minifier/issues/229 | // https://github.com/kangax/html-minifier/issues/229 | |||
assert.equal(minify('<CUSTOM-TAG></CUSTOM-TAG><div>Hello :)</div>'), '<custom- tag></custom-tag><div>Hello :)</div>'); | assert.equal(minify('<CUSTOM-TAG></CUSTOM-TAG><div>Hello :)</div>'), '<custom- tag></custom-tag><div>Hello :)</div>'); | |||
// https://github.com/kangax/html-minifier/issues/507 | // https://github.com/kangax/html-minifier/issues/507 | |||
input = '<tag v-ref:vm_pv :imgs=" objpicsurl_ "></tag>'; | input = '<tag v-ref:vm_pv :imgs=" objpicsurl_ "></tag>'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
input = '<tag v-ref:vm_pv :imgs=" objpicsurl_ " ss"123>'; | ||||
assert.throws(function() { | assert.throws(function() { | |||
minify('<tag v-ref:vm_pv :imgs=" objpicsurl_ " ss"123></tag>'); | minify(input); | |||
}, 'invalid attribute name'); | }, 'invalid attribute name'); | |||
assert.equal(minify(input, { | ||||
continueOnParseError: true, | ||||
}), input); | ||||
// https://github.com/kangax/html-minifier/issues/512 | // https://github.com/kangax/html-minifier/issues/512 | |||
input = '<input class="form-control" type="text" style="" id="{{vm.formInputNa me}}" name="{{vm.formInputName}}"' + | input = '<input class="form-control" type="text" style="" id="{{vm.formInputNa me}}" name="{{vm.formInputName}}"' + | |||
' placeholder="YYYY-MM-DD"' + | ' placeholder="YYYY-MM-DD"' + | |||
' date-range-picker' + | ' date-range-picker' + | |||
' data-ng-model="vm.value"' + | ' data-ng-model="vm.value"' + | |||
' data-ng-model-options="{ debounce: 1000 }"' + | ' data-ng-model-options="{ debounce: 1000 }"' + | |||
' data-ng-pattern="vm.options.format"' + | ' data-ng-pattern="vm.options.format"' + | |||
' data-options="vm.datepickerOptions">'; | ' data-options="vm.datepickerOptions">'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
input = '<input class="form-control" type="text" style="" id="{{vm.formInputNa | ||||
me}}" name="{{vm.formInputName}}"' + | ||||
' <!--FIXME hardcoded placeholder - dates may not be used for service | ||||
required fields yet. -->' + | ||||
' placeholder="YYYY-MM-DD"' + | ||||
' date-range-picker' + | ||||
' data-ng-model="vm.value"' + | ||||
' data-ng-model-options="{ debounce: 1000 }"' + | ||||
' data-ng-pattern="vm.options.format"' + | ||||
' data-options="vm.datepickerOptions">'; | ||||
assert.throws(function() { | assert.throws(function() { | |||
minify( | minify(input); | |||
'<input class="form-control" type="text" style="" id="{{vm.formInputName}} | ||||
" name="{{vm.formInputName}}"' + | ||||
' <!--FIXME hardcoded placeholder - dates may not be used for service requ | ||||
ired fields yet. -->' + | ||||
' placeholder="YYYY-MM-DD"' + | ||||
' date-range-picker' + | ||||
' data-ng-model="vm.value"' + | ||||
' data-ng-model-options="{ debounce: 1000 }"' + | ||||
' data-ng-pattern="vm.options.format"' + | ||||
' data-options="vm.datepickerOptions">' | ||||
); | ||||
}, 'HTML comment inside tag'); | }, 'HTML comment inside tag'); | |||
assert.equal(minify(input, { | ||||
continueOnParseError: true, | ||||
}), input); | ||||
// https://github.com/kangax/html-minifier/issues/974 | ||||
input = '<!–– Failing New York Times Comment -->'; | ||||
assert.throws(function() { | ||||
minify(input); | ||||
}, 'invalid HTML comment'); | ||||
assert.equal(minify(input, { | ||||
continueOnParseError: true, | ||||
}), input); | ||||
input = '<br a=\u00A0 b=" " c="\u00A0">'; | input = '<br a=\u00A0 b=" " c="\u00A0">'; | |||
output = '<br a="\u00A0" b=" " c="\u00A0">'; | output = '<br a="\u00A0" b=" " c="\u00A0">'; | |||
assert.equal(minify(input), output); | assert.equal(minify(input), output); | |||
output = '<br a="\u00A0"b="\u00A0"c="\u00A0">'; | output = '<br a="\u00A0"b="\u00A0"c="\u00A0">'; | |||
assert.equal(minify(input, { | assert.equal(minify(input, { | |||
decodeEntities: true, | decodeEntities: true, | |||
removeTagWhitespace: true, | removeTagWhitespace: true, | |||
}), output); | }), output); | |||
output = '<br a=\u00A0 b=\u00A0 c=\u00A0>'; | output = '<br a=\u00A0 b=\u00A0 c=\u00A0>'; | |||
skipping to change at line 1966 | skipping to change at line 1984 | |||
collapseWhitespace: true | collapseWhitespace: true | |||
}), output); | }), output); | |||
input = '<link href="<?php echo \'http://foo/\' ?>">'; | input = '<link href="<?php echo \'http://foo/\' ?>">'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
assert.equal(minify(input, { removeAttributeQuotes: true }), input); | assert.equal(minify(input, { removeAttributeQuotes: true }), input); | |||
input = '<pre>\nfoo\n<? bar ?>\nbaz\n</pre>'; | input = '<pre>\nfoo\n<? bar ?>\nbaz\n</pre>'; | |||
assert.equal(minify(input), input); | assert.equal(minify(input), input); | |||
assert.equal(minify(input, { collapseWhitespace: true }), input); | assert.equal(minify(input, { collapseWhitespace: true }), input); | |||
input = '<script>var value="<?php ?>+<?php ?>0"</script>'; | ||||
assert.equal(minify(input), input); | ||||
assert.equal(minify(input, { minifyJS: true }), input); | ||||
input = '<style>body{font-size:<%=1%>2pt}</style>'; | ||||
assert.equal(minify(input), input); | ||||
assert.equal(minify(input, { minifyCSS: true }), input); | ||||
}); | }); | |||
QUnit.test('bootstrap\'s span > button > span', function(assert) { | QUnit.test('bootstrap\'s span > button > span', function(assert) { | |||
var input = '<span class="input-group-btn">' + | var input = '<span class="input-group-btn">' + | |||
'\n <button class="btn btn-default" type="button">' + | '\n <button class="btn btn-default" type="button">' + | |||
'\n <span class="glyphicon glyphicon-search"></span>' + | '\n <span class="glyphicon glyphicon-search"></span>' + | |||
'\n </button>' + | '\n </button>' + | |||
'</span>'; | '</span>'; | |||
var output = '<span class=input-group-btn><button class="btn btn-default" type =button><span class="glyphicon glyphicon-search"></span></button></span>'; | var output = '<span class=input-group-btn><button class="btn btn-default" type =button><span class="glyphicon glyphicon-search"></span></button></span>'; | |||
assert.equal(minify(input, { collapseWhitespace: true, removeAttributeQuotes: true }), output); | assert.equal(minify(input, { collapseWhitespace: true, removeAttributeQuotes: true }), output); | |||
skipping to change at line 2835 | skipping to change at line 2861 | |||
output = '<body <?php body_class(); ?>>'; | output = '<body <?php body_class(); ?>>'; | |||
assert.equal(minify(input, { ignoreCustomFragments: [/<\?php[\s\S]*?\?>/] }), output); | assert.equal(minify(input, { ignoreCustomFragments: [/<\?php[\s\S]*?\?>/] }), output); | |||
input = 'a\n<!-- htmlmin:ignore -->b<!-- htmlmin:ignore -->'; | input = 'a\n<!-- htmlmin:ignore -->b<!-- htmlmin:ignore -->'; | |||
output = 'a b'; | output = 'a b'; | |||
assert.equal(minify(input, { collapseWhitespace: true }), output); | assert.equal(minify(input, { collapseWhitespace: true }), output); | |||
input = '<p>foo <!-- htmlmin:ignore --><span>\n\tbar\n</span><!-- htmlmin:igno re -->.</p>'; | input = '<p>foo <!-- htmlmin:ignore --><span>\n\tbar\n</span><!-- htmlmin:igno re -->.</p>'; | |||
output = '<p>foo <span>\n\tbar\n</span>.</p>'; | output = '<p>foo <span>\n\tbar\n</span>.</p>'; | |||
assert.equal(minify(input, { collapseWhitespace: true }), output); | assert.equal(minify(input, { collapseWhitespace: true }), output); | |||
input = '<!-- htmlmin:ignore -->+<!-- htmlmin:ignore -->0'; | ||||
assert.equal(minify(input), '+0'); | ||||
}); | }); | |||
QUnit.test('meta viewport', function(assert) { | QUnit.test('meta viewport', function(assert) { | |||
var input, output; | var input, output; | |||
input = '<meta name="viewport" content="width=device-width, initial-scale=1.0" >'; | input = '<meta name="viewport" content="width=device-width, initial-scale=1.0" >'; | |||
output = '<meta name="viewport" content="width=device-width,initial-scale=1">' ; | output = '<meta name="viewport" content="width=device-width,initial-scale=1">' ; | |||
assert.equal(minify(input), output); | assert.equal(minify(input), output); | |||
input = '<meta name="viewport" content="initial-scale=1, maximum-scale=1.0">'; | input = '<meta name="viewport" content="initial-scale=1, maximum-scale=1.0">'; | |||
skipping to change at line 3531 | skipping to change at line 3560 | |||
// the hooks returned false: | // the hooks returned false: | |||
input = '<div class="leaveAlone"></div><div> foo bar </div>'; | input = '<div class="leaveAlone"></div><div> foo bar </div>'; | |||
output = '<div class="leaveAlone"></div><div>foo bar</div>'; | output = '<div class="leaveAlone"></div><div>foo bar</div>'; | |||
assert.equal(minify(input, { | assert.equal(minify(input, { | |||
collapseWhitespace: true, | collapseWhitespace: true, | |||
canTrimWhitespace: canCollapseAndTrimWhitespace, | canTrimWhitespace: canCollapseAndTrimWhitespace, | |||
canCollapseWhitespace: canCollapseAndTrimWhitespace | canCollapseWhitespace: canCollapseAndTrimWhitespace | |||
}), output); | }), output); | |||
}); | }); | |||
QUnit.test('minify Content-Security-Policy', function(assert) { | ||||
var input, output; | ||||
input = '<meta Http-Equiv="Content-Security-Policy"\t\t\t\tContent="default-sr | ||||
c \'self\';\n\n\t\timg-src https://*;">'; | ||||
output = '<meta http-equiv="Content-Security-Policy" content="default-src \'se | ||||
lf\'; img-src https://*;">'; | ||||
assert.equal(minify(input), output); | ||||
input = '<meta http-equiv="content-security-policy"\t\t\t\tcontent="default-sr | ||||
c \'self\';\n\n\t\timg-src https://*;">'; | ||||
output = '<meta http-equiv="content-security-policy" content="default-src \'se | ||||
lf\'; img-src https://*;">'; | ||||
assert.equal(minify(input), output); | ||||
input = '<meta http-equiv="content-security-policy" content="default-src \'sel | ||||
f\'; img-src https://*;">'; | ||||
assert.equal(minify(input), input); | ||||
}); | ||||
End of changes. 10 change blocks. | ||||
13 lines changed or deleted | 42 lines changed or added |