return attrValue;
}
+ var reEmptyAttribute = new RegExp(
+ '^(?:class|id|style|title|lang|dir|on(?:focus|blur|change|click|dblclick|mouse(' +
+ '?:down|up|over|move|out)|key(?:press|down|up)))$');
+
function canDeleteEmptyAttribute(tag, attrName, attrValue) {
var isValueEmpty = /^(["'])?\s*\1$/.test(attrValue);
return (
(tag === 'input' && attrName === 'value') ||
- /^(?:class|id|style|title|lang|dir|on(?:click|dblclick|mouse(?:down|up|over|move|out)|key(?:press|down|up)))$/.test(attrName)
- );
+ reEmptyAttribute.test(attrName));
}
return false;
}
equals(minify(input, { shouldRemoveComments: true }), input);
});
+ test('empty attributes', function(){
+ var input = '<p id="" class="" style=" " title="\n" lang="" dir="">x</p>';
+ equals(minify(input, { shouldRemoveEmptyAttributes: true }), '<p>x</p>');
+
+ input = '<p onclick="" ondblclick=" " onmousedown="" onmouseup="" onmouseover=" " onmousemove="" onmouseout="" '+
+ 'onkeypress=\n\n "\n " onkeydown=\n"" onkeyup\n="">x</p>';
+ equals(minify(input, { shouldRemoveEmptyAttributes: true }), '<p>x</p>');
+
+ input = '<input onfocus="" onblur="" onchange=" " value=" boo ">';
+ equals(minify(input, { shouldRemoveEmptyAttributes: true }), '<input value=" boo ">');
+
+ input = '<input value="" name="foo">';
+ equals(minify(input, { shouldRemoveEmptyAttributes: true }), '<input name="foo">');
+ });
+
})(this);
</script>
+ <input type="input" title=" ">
</body>
</html>
\ No newline at end of file