]> source.dussan.org Git - jquery.git/commitdiff
dealing with boolean content attribute
authoraFarkas <info@corrupt-system.de>
Sat, 23 Apr 2011 09:29:07 +0000 (11:29 +0200)
committertimmywil <tim.willison@thisismedium.com>
Mon, 25 Apr 2011 16:41:12 +0000 (12:41 -0400)
src/attributes.js

index c2557633f777880eda3d22d7f44ab2af1aabcd52..990884484f52d083763ea0318267041aafd9d579 100644 (file)
@@ -311,7 +311,7 @@ jQuery.extend({
 
                if ( value !== undefined ) {
 
-                       if ( value === null ) {
+                       if ( value === null || value === false ) {
                                jQuery.removeAttr( elem, name );
                                return undefined;
 
@@ -319,6 +319,9 @@ jQuery.extend({
                                return ret;
 
                        } else {
+                               if( value === true ){
+                                       value = name;
+                               }
                                elem.setAttribute( name, "" + value );
                                return value;
                        }
@@ -478,20 +481,6 @@ if ( !jQuery.support.getSetAttribute ) {
        });
 }
 
-// Remove certain attrs if set to false
-jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name ) {
-       jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
-               set: function( elem, value ) {
-                       if ( value === true ) {
-                               elem.setAttribute( name, name );
-                               return value;
-                       } else if ( value === false ) {
-                               jQuery.removeAttr( elem, name );
-                               return value;
-                       }
-               }
-       });
-});
 
 // Some attributes require a special call on IE
 if ( !jQuery.support.hrefNormalized ) {