diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2011-09-19 21:07:07 -0400 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-09-19 21:07:07 -0400 |
commit | ca4133cc3fb4202d08de0d9e9d05e2442be63653 (patch) | |
tree | 319987a9731ec0896735215bc98fcd29ab740519 /src/attributes.js | |
parent | f60213648cefa9b53289ad01a55ead22a15e6ee1 (diff) | |
download | jquery-ca4133cc3fb4202d08de0d9e9d05e2442be63653.tar.gz jquery-ca4133cc3fb4202d08de0d9e9d05e2442be63653.zip |
Landing pull request 492. 1.7 Remove multiple attributes (Symmetry with removeClass) Combines patches submitted by leeoniya, zertosh and my own tests. Fixes #5479.
More Details:
- https://github.com/jquery/jquery/pull/492
- http://bugs.jquery.com/ticket/5479
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/attributes.js b/src/attributes.js index 91b53f97e..71353cf78 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -362,18 +362,26 @@ jQuery.extend({ } }, - removeAttr: function( elem, name ) { - var propName; + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + if ( elem.nodeType === 1 ) { - name = jQuery.attrFix[ name ] || name; + attrNames = (value || "").split( rspace ); + l = attrNames.length; - // See #9699 for explanation of this approach (setting first, then removal) - jQuery.attr( elem, name, "" ); - elem.removeAttribute( name ); + for ( ; i < l; i++ ) { + name = attrNames[ i ]; + name = jQuery.attrFix[ name ] || name; - // Set corresponding property to false for boolean attributes - if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { - elem[ propName ] = false; + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( name ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { + elem[ propName ] = false; + } } } }, |