Skip to content

Commit

Permalink
dealing with boolean content attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas authored and timmywil committed Apr 25, 2011
1 parent 02ad0aa commit 9559b1a
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,17 @@ jQuery.extend({

if ( value !== undefined ) {

if ( value === null ) {
if ( value === null || value === false ) {
jQuery.removeAttr( elem, name );
return undefined;

} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;

} else {
if( value === true ){
value = name;
}
elem.setAttribute( name, "" + value );
return value;
}
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 9559b1a

Please sign in to comment.