}
function canRemoveAttributeQuotes(value) {
- // http://www.w3.org/TR/html4/intro/sgmltut.html#attributes
- // avoid \w, which could match unicode in some implementations
- return (/^[a-zA-Z0-9-._:]+$/).test(value);
+ // http://mathiasbynens.be/notes/unquoted-attribute-values
+ return /^[^\x20\t\n\f\r"'`=<>]+$/.test(value);
}
function attributesInclude(attributes, attribute) {
equal(minify(input, { removeAttributeQuotes: true }), '<input value="hello world">');
input = '<a href="#" title="foo#bar">x</a>';
- equal(minify(input, { removeAttributeQuotes: true }), '<a href="#" title="foo#bar">x</a>');
+ equal(minify(input, { removeAttributeQuotes: true }), '<a href=# title=foo#bar>x</a>');
- input = '<a href="http://example.com" title="blah">\nfoo\n\n</a>';
- equal(minify(input, { removeAttributeQuotes: true }), '<a href="http://example.com" title=blah>\nfoo\n\n</a>');
+ input = '<a href="http://example.com/" title="blah">\nfoo\n\n</a>';
+ equal(minify(input, { removeAttributeQuotes: true }), '<a href=http://example.com/ title=blah>\nfoo\n\n</a>');
+
+ input = '<p class=foo|bar:baz></p>';
+ equal(minify(input, { removeAttributeQuotes: true }), '<p class=foo|bar:baz></p>');
});
test('collapsing whitespace', function() {