From 2a8a2b61488e7857b116bedc9eb75bd971772c2f Mon Sep 17 00:00:00 2001 From: timmywil Date: Sun, 3 Apr 2011 16:49:48 -0400 Subject: [PATCH] Move the if statement in jQuery.fn.removeAttr to jQuery.removeAttr - Extra testing on removeAttr and IE form weirdness( all good ) --- src/attributes.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 7c03cddb..b472e617 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -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 ) ); + } } },