diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2015-12-22 13:03:11 -0500 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2016-01-06 14:05:11 -0500 |
commit | e3c89685095cfabdd1060b5d9cb57a62f60b7f2f (patch) | |
tree | 5f64b9a32e6f1add52364f1638c86c7671cc41cf /src/attributes/val.js | |
parent | f21d43a1146256379d7f5b7cb537ed59aeebdeb4 (diff) | |
download | jquery-e3c89685095cfabdd1060b5d9cb57a62f60b7f2f.tar.gz jquery-e3c89685095cfabdd1060b5d9cb57a62f60b7f2f.zip |
Revert "Misc: Drop support for older browsers; update support comments"
This reverts commit 90d7cc1d8b2ea7ac75f0eacb42439349c9c73278.
Diffstat (limited to 'src/attributes/val.js')
-rw-r--r-- | src/attributes/val.js | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/attributes/val.js b/src/attributes/val.js index 7af79cfef..d4ed96f31 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -78,10 +78,13 @@ jQuery.extend( { valHooks: { option: { get: function( elem ) { + var val = jQuery.find.attr( elem, "value" ); + return val != null ? + val : - // Support: IE<11 - // option.value not trimmed (#14858) - return jQuery.trim( elem.value ); + // Support: IE10-11+ + // option.text throws exceptions (#14686, #14858) + jQuery.trim( jQuery.text( elem ) ); } }, select: { @@ -100,8 +103,7 @@ jQuery.extend( { for ( ; i < max; i++ ) { option = options[ i ]; - // Support: IE<10 - // IE8-9 doesn't update selected after form reset (#2551) + // oldIE doesn't update selected after form reset (#2551) if ( ( option.selected || i === index ) && // Don't return options that are disabled or in a disabled optgroup @@ -135,11 +137,24 @@ jQuery.extend( { while ( i-- ) { option = options[ i ]; - if ( - option.selected = - jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 - ) { - optionSet = true; + + if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { + + // Support: IE6 + // When new option element is added to select box we need to + // force reflow of newly added node in order to workaround delay + // of initialization properties + try { + option.selected = optionSet = true; + + } catch ( _ ) { + + // Will be executed only in IE6 + option.scrollHeight; + } + + } else { + option.selected = false; } } |