Commit d723942b authored by timmywil's avatar timmywil

Revert back to always setting the attribute to empty string before removal. Fixes #9699.

parent e5705773
...@@ -366,14 +366,9 @@ jQuery.extend({ ...@@ -366,14 +366,9 @@ jQuery.extend({
var propName; var propName;
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name; name = jQuery.attrFix[ name ] || name;
if ( jQuery.support.getSetAttribute ) { jQuery.attr( elem, name, "" );
// Use removeAttribute in browsers that support it elem.removeAttribute( name );
elem.removeAttribute( name );
} else {
jQuery.attr( elem, name, "" );
elem.removeAttributeNode( elem.getAttributeNode( name ) );
}
// Set corresponding property to false for boolean attributes // Set corresponding property to false for boolean attributes
if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
......
...@@ -451,17 +451,18 @@ test("attr('tabindex', value)", function() { ...@@ -451,17 +451,18 @@ test("attr('tabindex', value)", function() {
}); });
test("removeAttr(String)", function() { test("removeAttr(String)", function() {
expect(7); expect(8);
equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" ); equal( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" ); equal( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" ); equal( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" ); equal( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" ); equal( jQuery("<div style='position: absolute'></div>").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" );
equal( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked"); jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" ); equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
jQuery("#text1").prop("readOnly", true).removeAttr("readonly"); jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
equals( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" ); equal( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
}); });
test("prop(String, Object)", function() { test("prop(String, Object)", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment