diff options
author | Michał Gołębiowski <m.goleb@gmail.com> | 2014-12-04 14:43:35 +0100 |
---|---|---|
committer | Michał Gołębiowski <m.goleb@gmail.com> | 2014-12-08 22:39:58 +0100 |
commit | f6302b0b53d61dfe1adbfaf6612be5cbced5bbc1 (patch) | |
tree | 2d022973ed69d45edeab202eab6be03a94373e23 /src | |
parent | dd596ccf729b2f39d44b73bc54b53bd41c880146 (diff) | |
download | jquery-f6302b0b53d61dfe1adbfaf6612be5cbced5bbc1.tar.gz jquery-f6302b0b53d61dfe1adbfaf6612be5cbced5bbc1.zip |
Attributes: Use the option val hook in select val hook and simplify it
The hook is still defined; not using it could cause issues in IE<11.
Also, IE10 no longer throws when value not set but it still doesn't trim the
value. IE11 has all those issues fixed; support comments are updated.
Fixes gh-1902
Closes gh-1901
Diffstat (limited to 'src')
-rw-r--r-- | src/attributes/val.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/attributes/val.js b/src/attributes/val.js index f67afb156..c5e8c63f4 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -74,12 +74,9 @@ jQuery.extend({ valHooks: { option: { get: function( elem ) { - var val = jQuery.find.attr( elem, "value" ); - return val != null ? - val : - // Support: IE10-11+ - // option.text throws exceptions (#14686, #14858) - jQuery.trim( jQuery.text( elem ) ); + // Support: IE<11 + // option.value not trimmed (#14858) + return jQuery.trim( elem.value ); } }, select: { @@ -130,7 +127,8 @@ jQuery.extend({ while ( i-- ) { option = options[ i ]; - if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { + if ( (option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0) ) { optionSet = true; } } |