]> source.dussan.org Git - jquery.git/commitdiff
Move the if statement in jQuery.fn.removeAttr to jQuery.removeAttr
authortimmywil <tim.willison@thisismedium.com>
Sun, 3 Apr 2011 20:49:48 +0000 (16:49 -0400)
committertimmywil <tim.willison@thisismedium.com>
Sun, 3 Apr 2011 23:13:41 +0000 (19:13 -0400)
- Extra testing on removeAttr and IE form weirdness( all good )

src/attributes.js

index 7c03cddbea77c19ac6dc91d6fec78be8b9307a18..b472e617cfe516a4b7c753d543a69bb199501fe7 100644 (file)
@@ -16,9 +16,7 @@ jQuery.fn.extend({
 
        removeAttr: function( name ) {
                return this.each(function() {
-                       if ( this.nodeType === 1 ) {
-                               jQuery.removeAttr( this, name );
-                       }
+                       jQuery.removeAttr( this, name );
                });
        },
        
@@ -335,15 +333,17 @@ jQuery.extend({
        },
        
        removeAttr: function( elem, name ) {
-               name = jQuery.attrFix[ name ] || name;
+               if ( elem.nodeType === 1 ) {
+                       name = jQuery.attrFix[ name ] || name;
                
-               if ( jQuery.support.getSetAttribute ) {
-                       elem.removeAttribute( name );
-               } else {
-                       // Set to default empty string
-                       elem.setAttribute( name, "" );
-                       // Attempt to remove completely with DOM level 1
-                       elem.removeAttributeNode( elem.getAttributeNode( name ) );
+                       if ( jQuery.support.getSetAttribute ) {
+                               elem.removeAttribute( name );
+                       } else {
+                               // Set to default empty string (No longer need to use attr for this)
+                               elem.setAttribute( name, "" );
+                               // Attempt to remove completely with DOM level 1
+                               elem.removeAttributeNode( elem.getAttributeNode( name ) );
+                       }
                }
        },