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

Skip to content

Commit 736bbfc

Browse files
mgolrickypowell
authored andcommitted
Manipulation: Skip the select wrapper for <option> outside of IE 9
Closes jquerygh-4647
1 parent 5147028 commit 736bbfc

File tree

3 files changed

+273
-9
lines changed

3 files changed

+273
-9
lines changed

src/manipulation/support.js

Lines changed: 6 additions & 0 deletions
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

Lines changed: 8 additions & 7 deletions
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

Lines changed: 259 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,265 @@ testIframe(
5555
);
5656

5757
( function() {
58-
var expected,
59-
userAgent = window.navigator.userAgent;
58+
var browserKey, expected,
59+
userAgent = window.navigator.userAgent,
60+
expectedMap = {
61+
edge: {
62+
"ajax": true,
63+
"boxSizingReliable": true,
64+
"checkClone": true,
65+
"checkOn": true,
66+
"clearCloneStyle": true,
67+
"cors": true,
68+
"createHTMLDocument": true,
69+
"focusin": false,
70+
"noCloneChecked": true,
71+
"option": true,
72+
"optSelected": true,
73+
"pixelBoxStyles": true,
74+
"pixelPosition": true,
75+
"radioValue": true,
76+
"reliableMarginLeft": true,
77+
"reliableTrDimensions": false,
78+
"scrollboxSize": true
79+
},
80+
ie_10_11: {
81+
"ajax": true,
82+
"boxSizingReliable": false,
83+
"checkClone": true,
84+
"checkOn": true,
85+
"clearCloneStyle": false,
86+
"cors": true,
87+
"createHTMLDocument": true,
88+
"focusin": true,
89+
"noCloneChecked": false,
90+
"option": true,
91+
"optSelected": false,
92+
"pixelBoxStyles": true,
93+
"pixelPosition": true,
94+
"radioValue": false,
95+
"reliableMarginLeft": true,
96+
"reliableTrDimensions": false,
97+
"scrollboxSize": true
98+
},
99+
ie_9: {
100+
"ajax": true,
101+
"boxSizingReliable": false,
102+
"checkClone": true,
103+
"checkOn": true,
104+
"clearCloneStyle": false,
105+
"cors": false,
106+
"createHTMLDocument": true,
107+
"focusin": true,
108+
"noCloneChecked": false,
109+
"option": false,
110+
"optSelected": false,
111+
"pixelBoxStyles": true,
112+
"pixelPosition": true,
113+
"radioValue": false,
114+
"reliableMarginLeft": true,
115+
"reliableTrDimensions": false,
116+
"scrollboxSize": false
117+
},
118+
chrome: {
119+
"ajax": true,
120+
"boxSizingReliable": true,
121+
"checkClone": true,
122+
"checkOn": true,
123+
"clearCloneStyle": true,
124+
"cors": true,
125+
"createHTMLDocument": true,
126+
"focusin": false,
127+
"noCloneChecked": true,
128+
"option": true,
129+
"optSelected": true,
130+
"pixelBoxStyles": true,
131+
"pixelPosition": true,
132+
"radioValue": true,
133+
"reliableMarginLeft": true,
134+
"reliableTrDimensions": true,
135+
"scrollboxSize": true
136+
},
137+
safari: {
138+
"ajax": true,
139+
"boxSizingReliable": true,
140+
"checkClone": true,
141+
"checkOn": true,
142+
"clearCloneStyle": true,
143+
"cors": true,
144+
"createHTMLDocument": true,
145+
"focusin": false,
146+
"noCloneChecked": true,
147+
"option": true,
148+
"optSelected": true,
149+
"pixelBoxStyles": true,
150+
"pixelPosition": true,
151+
"radioValue": true,
152+
"reliableMarginLeft": true,
153+
"reliableTrDimensions": true,
154+
"scrollboxSize": true
155+
},
156+
safari_9_10: {
157+
"ajax": true,
158+
"boxSizingReliable": true,
159+
"checkClone": true,
160+
"checkOn": true,
161+
"clearCloneStyle": true,
162+
"cors": true,
163+
"createHTMLDocument": true,
164+
"focusin": false,
165+
"noCloneChecked": true,
166+
"option": true,
167+
"optSelected": true,
168+
"pixelBoxStyles": false,
169+
"pixelPosition": false,
170+
"radioValue": true,
171+
"reliableMarginLeft": true,
172+
"reliableTrDimensions": true,
173+
"scrollboxSize": true
174+
},
175+
firefox: {
176+
"ajax": true,
177+
"boxSizingReliable": true,
178+
"checkClone": true,
179+
"checkOn": true,
180+
"clearCloneStyle": true,
181+
"cors": true,
182+
"createHTMLDocument": true,
183+
"focusin": false,
184+
"noCloneChecked": true,
185+
"option": true,
186+
"optSelected": true,
187+
"pixelBoxStyles": true,
188+
"pixelPosition": true,
189+
"radioValue": true,
190+
"reliableMarginLeft": true,
191+
"reliableTrDimensions": true,
192+
"scrollboxSize": true
193+
},
194+
firefox_60: {
195+
"ajax": true,
196+
"boxSizingReliable": true,
197+
"checkClone": true,
198+
"checkOn": true,
199+
"clearCloneStyle": true,
200+
"cors": true,
201+
"createHTMLDocument": true,
202+
"focusin": false,
203+
"noCloneChecked": true,
204+
"option": true,
205+
"optSelected": true,
206+
"pixelBoxStyles": true,
207+
"pixelPosition": true,
208+
"radioValue": true,
209+
"reliableMarginLeft": false,
210+
"reliableTrDimensions": true,
211+
"scrollboxSize": true
212+
},
213+
ios: {
214+
"ajax": true,
215+
"boxSizingReliable": true,
216+
"checkClone": true,
217+
"checkOn": true,
218+
"clearCloneStyle": true,
219+
"cors": true,
220+
"createHTMLDocument": true,
221+
"focusin": false,
222+
"noCloneChecked": true,
223+
"option": true,
224+
"optSelected": true,
225+
"pixelBoxStyles": true,
226+
"pixelPosition": true,
227+
"radioValue": true,
228+
"reliableMarginLeft": true,
229+
"reliableTrDimensions": true,
230+
"scrollboxSize": true
231+
},
232+
ios_9_10: {
233+
"ajax": true,
234+
"boxSizingReliable": true,
235+
"checkClone": true,
236+
"checkOn": true,
237+
"clearCloneStyle": true,
238+
"cors": true,
239+
"createHTMLDocument": true,
240+
"focusin": false,
241+
"noCloneChecked": true,
242+
"option": true,
243+
"optSelected": true,
244+
"pixelBoxStyles": false,
245+
"pixelPosition": false,
246+
"radioValue": true,
247+
"reliableMarginLeft": true,
248+
"reliableTrDimensions": true,
249+
"scrollboxSize": true
250+
},
251+
ios_8: {
252+
"ajax": true,
253+
"boxSizingReliable": true,
254+
"checkClone": true,
255+
"checkOn": true,
256+
"clearCloneStyle": true,
257+
"cors": true,
258+
"createHTMLDocument": false,
259+
"focusin": false,
260+
"noCloneChecked": true,
261+
"option": true,
262+
"optSelected": true,
263+
"pixelBoxStyles": false,
264+
"pixelPosition": false,
265+
"radioValue": true,
266+
"reliableMarginLeft": true,
267+
"reliableTrDimensions": true,
268+
"scrollboxSize": true
269+
},
270+
ios_7: {
271+
"ajax": true,
272+
"boxSizingReliable": true,
273+
"checkClone": true,
274+
"checkOn": true,
275+
"clearCloneStyle": true,
276+
"cors": true,
277+
"createHTMLDocument": true,
278+
"focusin": false,
279+
"noCloneChecked": true,
280+
"option": true,
281+
"optSelected": true,
282+
"pixelBoxStyles": false,
283+
"pixelPosition": false,
284+
"radioValue": true,
285+
"reliableMarginLeft": true,
286+
"reliableTrDimensions": true,
287+
"scrollboxSize": true
288+
},
289+
android: {
290+
"ajax": true,
291+
"boxSizingReliable": true,
292+
"checkClone": false,
293+
"checkOn": false,
294+
"clearCloneStyle": true,
295+
"cors": true,
296+
"createHTMLDocument": true,
297+
"focusin": false,
298+
"noCloneChecked": true,
299+
"option": true,
300+
"optSelected": true,
301+
"pixelBoxStyles": false,
302+
"pixelPosition": false,
303+
"radioValue": true,
304+
"reliableMarginLeft": false,
305+
"reliableTrDimensions": true,
306+
"scrollboxSize": true
307+
}
308+
};
309+
310+
// Make the slim build pass tests.
311+
for ( browserKey in expectedMap ) {
312+
if ( !jQuery.ajax ) {
313+
delete expectedMap[ browserKey ].ajax;
314+
delete expectedMap[ browserKey ].cors;
315+
}
316+
}
60317

61318
if ( /edge\//i.test( userAgent ) ) {
62319
expected = {

0 commit comments

Comments
 (0)
0