aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2016-01-15 16:48:52 -0500
committerTimmy Willison <timmywillisn@gmail.com>2016-01-19 11:36:47 -0500
commit780cac802b32a0125c467a644b3803be378ae6ab (patch)
tree5aeee2370206a4a455b629abcf182115b3857cf4 /src
parentfe05cf37ffd4795988f9b2343df2182e108728ca (diff)
downloadjquery-780cac802b32a0125c467a644b3803be378ae6ab.tar.gz
jquery-780cac802b32a0125c467a644b3803be378ae6ab.zip
Attributes: fix setting selected on an option in IE<=11
Fixes gh-2732 Close gh-2840
Diffstat (limited to 'src')
-rw-r--r--src/attributes/prop.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/attributes/prop.js b/src/attributes/prop.js
index da7bc1e86..15128b8ce 100644
--- a/src/attributes/prop.js
+++ b/src/attributes/prop.js
@@ -79,6 +79,12 @@ jQuery.extend( {
}
} );
+// Support: IE <=11 only
+// Accessing the selectedIndex property
+// forces the browser to respect setting selected
+// on the option
+// The getter ensures a default option is selected
+// when in an optgroup
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
@@ -87,6 +93,16 @@ if ( !support.optSelected ) {
parent.parentNode.selectedIndex;
}
return null;
+ },
+ set: function( elem ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ if ( parent && parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
}
};
}