Skip to content
Permalink
Browse files

dealing with boolean content attribute

  • Loading branch information...
aFarkas timmywil
aFarkas authored and timmywil committed Apr 23, 2011
1 parent 02ad0aa commit 9559b1a294af42d4c12d20b8af7a8422903b0a73
Showing with 4 additions and 15 deletions.
  1. +4 −15 src/attributes.js
@@ -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;
}
@@ -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 ) {

0 comments on commit 9559b1a

Please sign in to comment.
You can’t perform that action at this time.