8000 Manipulation: Skip the select wrapper for <option> outside of IE 9 · jquery/jquery@966a709 · GitHub
[go: up one dir, main page]

Skip to content

Commit 966a709

Browse files
authored
Manipulation: Skip the select wrapper for <option> outside of IE 9
Closes gh-4647
1 parent 1d61fd9 commit 966a709

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/manipulation/support.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ define( [
2828
// Make sure textarea (and checkbox) defaultValue is properly cloned
2929
div.innerHTML = "<textarea>x</textarea>";
3030
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
31+
32+
// Support: IE <=9 only
33+
// IE <=9 replaces <option> tags with their contents when inserted outside of
34+
// the select element.
35+
div.innerHTML = "<option></option>";
36+
support.option = !!div.lastChild;
3137
} )();
3238

3339
return support;

src/manipulation/wrapMap.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
define( function() {
1+
define( [
2+
"./support"
3+
], function( support ) {
24

35
"use strict";
46

57
// We have to close these tags to support XHTML (#13200)
68
var wrapMap = {
79

8-
// Support: IE <=9 only
9-
option: [ 1, "<select multiple='multiple'>", "</select>" ],
10-
1110
// XHTML parsers do not magically insert elements in the
1211
// same way that tag soup parsers do. So we cannot shorten
1312
// this by omitting <tbody> or other required elements.
@@ -19,11 +18,13 @@ var wrapMap = {
1918
_default: [ 0, "", "" ]
2019
};
2120

22-
// Support: IE <=9 only
23-
wrapMap.optgroup = wrapMap.option;
24-
2521
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
2622
wrapMap.th = wrapMap.td;
2723

24+
// Support: IE <=9 only
25+
if ( !support.option ) {
26+
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
27+
}
28+
2829
return wrapMap;
2930
} );

test/unit/support.js

+13
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ testIframe(
6868
"createHTMLDocument": true,
6969
"focusin": false,
7070
"noCloneChecked": true,
71+
"option": true,
7172
"optSelected": true,
7273
"pixelBoxStyles": true,
7374
"pixelPosition": true,
@@ -86,6 +87,7 @@ testIframe(
8687
"createHTMLDocument": true,
8788
"focusin": true,
8889
"noCloneChecked": false,
90+
"option": true,
8991
"optSelected": false,
9092
"pixelBoxStyles": true,
9193
"pixelPosition": true,
@@ -104,6 +106,7 @@ testIframe(
104106
"createHTMLDocument": true,
105107
"focusin": true,
106108
"noCloneChecked": false,
109+
"option": false,
107110
"optSelected": false,
108111
"pixelBoxStyles": true,
109112
"pixelPosition": true,
@@ -122,6 +125,7 @@ testIframe(
122125
"createHTMLDocument": true,
123126
"focusin": false,
124127
"noCloneChecked": true,
128+
"option": true,
125129
"optSelected": true,
126130
"pixelBoxStyles": true,
127131
"pixelPosition": true,
@@ -140,6 +144,7 @@ testIframe(
140144
"createHTMLDocument": true,
141145
"focusin": false,
142146
"noCloneChecked": true,
147+
"option": true,
143148
"optSelected": true,
144149
"pixelBoxStyles": true,
145150
"pixelPosition": true,
@@ -158,6 +163,7 @@ testIframe(
158163
"createHTMLDocument": true,
159164
"focusin": false,
160165
"noCloneChecked": true,
166+
"option": true,
161167
"optSelected": true,
162168
"pixelBoxStyles": false,
163169
"pixelPosition": false,
@@ -176,6 +182,7 @@ testIframe(
176182
"createHTMLDocument": true,
177183
"focusin": false,
178184
"noCloneChecked": true,
185+
"option": true,
179186
"optSelected": true,
180187
"pixelBoxStyles": true,
181188
"pixelPosition": true,
@@ -194,6 +201,7 @@ testIframe(
194201
"createHTMLDocument": true,
195202
"focusin": false,
196203
"noCloneChecked": true,
204+
"option": true,
197205
"optSelected": true,
198206
"pixelBoxStyles": true,
199207
"pixelPosition": true,
@@ -212,6 +220,7 @@ testIframe(
212220
"createHTMLDocument": true,
213221
"focusin": false,
214222
"noCloneChecked": true,
223+
"option": true,
215224
"optSelected": true,
216225
"pixelBoxStyles": true,
217226
"pixelPosition": true,
@@ -230,6 +239,7 @@ testIframe(
230239
"createHTMLDocument": true,
231240
"focusin": false,
232241
"noCloneChecked": true,
242+
"option": true,
233243
"optSelected": true,
234244
"pixelBoxStyles": false,
235245
"pixelPosition": false,
@@ -248,6 +258,7 @@ testIframe(
248258
"createHTMLDocument": false,
249259
"focusin": false,
250260
"noCloneChecked": true,
261+
"option": true,
251262
"optSelected": true,
252263
"pixelBoxStyles": false,
253264
"pixelPosition": false,
@@ -266,6 +277,7 @@ testIframe(
266277
"createHTMLDocument": true,
267278
"focusin": false,
268279
"noCloneChecked": true,
280+
"option": true,
269281
"optSelected": true,
270282
"pixelBoxStyles": false,
271283
"pixelPosition": false,
@@ -284,6 +296,7 @@ testIframe(
284296
"createHTMLDocument": true,
285297
"focusin": false,
286298
"noCloneChecked": true,
299+
"option": true,
287300
"optSelected": true,
288301
"pixelBoxStyles": false,
289302
"pixelPosition": false,

0 commit comments

Comments
 (0)
0