Skip to content

Commit d723942

Browse files
committed
Revert back to always setting the attribute to empty string before removal. Fixes #9699.
1 parent e570577 commit d723942

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/attributes.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,9 @@ jQuery.extend({
366366
var propName;
367367
if ( elem.nodeType === 1 ) {
368368
name = jQuery.attrFix[ name ] || name;
369-
370-
if ( jQuery.support.getSetAttribute ) {
371-
// Use removeAttribute in browsers that support it
372-
elem.removeAttribute( name );
373-
} else {
374-
jQuery.attr( elem, name, "" );
375-
elem.removeAttributeNode( elem.getAttributeNode( name ) );
376-
}
369+
370+
jQuery.attr( elem, name, "" );
371+
elem.removeAttribute( name );
377372

378373
// Set corresponding property to false for boolean attributes
379374
if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {

test/unit/attributes.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,18 @@ test("attr('tabindex', value)", function() {
451451
});
452452

453453
test("removeAttr(String)", function() {
454-
expect(7);
455-
equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
456-
equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
457-
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
458-
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
459-
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" );
454+
expect(8);
455+
equal( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
456+
equal( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
457+
equal( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
458+
equal( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
459+
equal( jQuery("<div style='position: absolute'></div>").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" );
460+
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" );
460461

461462
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
462-
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
463+
equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
463464
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
464-
equals( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
465+
equal( document.getElementById("text1").readOnly, false, "removeAttr sets boolean properties to false" );
465466
});
466467

467468
test("prop(String, Object)", function() {

0 commit comments

Comments
 (0)