]> source.dussan.org Git - jquery.git/commitdiff
Add attribute name to paramaters for hooks
authortimmywil <tim.willison@thisismedium.com>
Sat, 26 Mar 2011 04:15:25 +0000 (00:15 -0400)
committertimmywil <tim.willison@thisismedium.com>
Sun, 3 Apr 2011 23:13:40 +0000 (19:13 -0400)
src/attributes.js

index c5f9dfbb5f9d2351e501f034ee55f8963dd402b9..6f6345747dc1e3b97eccd4b31c7ee8750cc622dc 100644 (file)
@@ -302,7 +302,7 @@ jQuery.extend({
                // Get the appropriate hook, or the formHook
                // if getSetAttribute is not supported and we have form objects in IE6/7
                hooks = formHook && ( name === "name" || elem.nodeName === "FORM" ) ?
-                                       formHook( name ) :
+                                       jQuery.attrHooks[ name ] || formHook :
                                        jQuery.attrHooks[ name ];
 
                if ( value !== undefined ) {
@@ -311,7 +311,7 @@ jQuery.extend({
                                jQuery.removeAttr( elem, name );
                                return undefined;
 
-                       } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value )) !== undefined ) {
+                       } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
                                return ret;
 
                        } else {
@@ -322,7 +322,7 @@ jQuery.extend({
                } else {
 
                        if ( hooks && "get" in hooks && notxml ) {
-                               return hooks.get( elem );
+                               return hooks.get( elem, name );
 
                        } else {
 
@@ -428,27 +428,25 @@ if ( !jQuery.support.getSetAttribute ) {
        
        // Use this for any attribute on a form in IE6/7
        // And the name attribute
-       formHook = function( name ) {
-               return jQuery.attrHooks[ name ] || {
-                       get: function( elem ) {
-                               var ret = elem.getAttributeNode( name );
-                               // Return undefined if not specified instead of empty string
-                               return ret && ret.specified ?
-                                       ret.nodeValue :
-                                       undefined;
-                       },
-                       set: function( elem, value ) {
-                               // Check form objects in IE (multiple bugs related)
-                               // Only use nodeValue if the attribute node exists on the form
-                               var ret = elem.getAttributeNode( name );
-                               if ( ret ) {
-                                       ret.nodeValue = value;
-                               } else {
-                                       elem.setAttribute( name, value );
-                               }
-                               return value;
+       formHook = {
+               get: function( elem, name ) {
+                       var ret = elem.getAttributeNode( name );
+                       // Return undefined if not specified instead of empty string
+                       return ret && ret.specified ?
+                               ret.nodeValue :
+                               undefined;
+               },
+               set: function( elem, value, name ) {
+                       // Check form objects in IE (multiple bugs related)
+                       // Only use nodeValue if the attribute node exists on the form
+                       var ret = elem.getAttributeNode( name );
+                       if ( ret ) {
+                               ret.nodeValue = value;
+                       } else {
+                               elem.setAttribute( name, value );
                        }
-               };
+                       return value;
+               }
        };
 }