diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-05-04 15:53:00 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-05-04 15:53:00 -0400 |
commit | 5195335cf4df62c06488807ae857f64c2d549253 (patch) | |
tree | e73edc443de73b55b9a02f802b2054e318a87d6e /src/attributes.js | |
parent | 3ed4b22073767c17c099351637514f5928c0fd68 (diff) | |
download | jquery-5195335cf4df62c06488807ae857f64c2d549253.tar.gz jquery-5195335cf4df62c06488807ae857f64c2d549253.zip |
Set the property corresponding to a boolean attribute when setting to true. Fixes #9103.
- Once boolean properties had been modified natively, setting the attribute no longer set the current value
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/attributes.js b/src/attributes.js index 97638632c..991c2a204 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -301,7 +301,7 @@ jQuery.extend({ return jQuery( elem )[ name ]( value ); } - var ret, hooks, + var ret, hooks, boolProp, notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); // Normalize the name if needed @@ -326,7 +326,12 @@ jQuery.extend({ } else { // Set boolean attributes to the same name + // Also set the DOM property if ( value === true && !rspecial.test( name ) ) { + boolProp = jQuery.propFix[ name ] || name; + if ( !rinvalidChar.test( boolProp ) && typeof elem[ boolProp ] === "boolean" ) { + elem[ boolProp ] = true; + } value = name.toLowerCase(); } @@ -338,7 +343,6 @@ jQuery.extend({ return hooks.get( elem, name ); } else { - var boolProp; // Align boolean attributes with corresponding properties // Do not check the property if the name contains characters |