aboutsummaryrefslogtreecommitdiffstats
path: root/src/manipulation
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-03-30 20:15:09 +0200
committerGitHub <noreply@github.com>2020-03-30 20:15:09 +0200
commit966a70909019aa09632c87c0002c522fa4a1e30e (patch)
tree8c980af2a3807cac812ab7a0376002bfffea02c1 /src/manipulation
parent1d61fd9407e6fbe82fe55cb0b938307aa0791f77 (diff)
downloadjquery-966a70909019aa09632c87c0002c522fa4a1e30e.tar.gz
jquery-966a70909019aa09632c87c0002c522fa4a1e30e.zip
Manipulation: Skip the select wrapper for <option> outside of IE 9
Closes gh-4647
Diffstat (limited to 'src/manipulation')
-rw-r--r--src/manipulation/support.js6
-rw-r--r--src/manipulation/wrapMap.js15
2 files changed, 14 insertions, 7 deletions
diff --git a/src/manipulation/support.js b/src/manipulation/support.js
index 4a5d9af4c..62d6bb3e0 100644
--- a/src/manipulation/support.js
+++ b/src/manipulation/support.js
@@ -28,6 +28,12 @@ define( [
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+ // Support: IE <=9 only
+ // IE <=9 replaces <option> tags with their contents when inserted outside of
+ // the select element.
+ div.innerHTML = "<option></option>";
+ support.option = !!div.lastChild;
} )();
return support;
diff --git a/src/manipulation/wrapMap.js b/src/manipulation/wrapMap.js
index 1f446f7d7..da48bf9fe 100644
--- a/src/manipulation/wrapMap.js
+++ b/src/manipulation/wrapMap.js
@@ -1,13 +1,12 @@
-define( function() {
+define( [
+ "./support"
+], function( support ) {
"use strict";
// We have to close these tags to support XHTML (#13200)
var wrapMap = {
- // Support: IE <=9 only
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
-
// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
@@ -19,11 +18,13 @@ var wrapMap = {
_default: [ 0, "", "" ]
};
-// Support: IE <=9 only
-wrapMap.optgroup = wrapMap.option;
-
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
+// Support: IE <=9 only
+if ( !support.option ) {
+ wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
+}
+
return wrapMap;
} );