diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-04-21 21:33:09 -0400 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2011-04-21 21:33:09 -0400 |
commit | 3ac9eb7ce37b461a34e303e8b77aa544d313441c (patch) | |
tree | 50cf69cf2e5d6c4e670ecd4757e0f12e48b010b8 /src/attributes.js | |
parent | dbe966aa57ce10d6c93db46eb2f3369a39e10d01 (diff) | |
download | jquery-3ac9eb7ce37b461a34e303e8b77aa544d313441c.tar.gz jquery-3ac9eb7ce37b461a34e303e8b77aa544d313441c.zip |
Landing pull request [337](https://github.com/jquery/jquery/pull/337). Value of radio inputs resets when type is set after the value in all IEs. Fixes #8570 ([bug](http://bugs.jquery.com/ticket/8570)).
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/attributes.js b/src/attributes.js index ac832591a..a296ad112 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -360,6 +360,15 @@ jQuery.extend({ // We can't allow the type property to be changed (since it causes problems in IE) if ( rtype.test( elem.nodeName ) && elem.parentNode ) { jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + var val = elem.getAttribute("value"); + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; } } }, @@ -432,7 +441,6 @@ if ( !jQuery.support.getSetAttribute ) { }); // Use this for any attribute on a form in IE6/7 - // And the name attribute formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = { get: function( elem, name ) { if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) { |