]> source.dussan.org Git - jquery.git/commitdiff
Manipulation: Skip the select wrapper for <option> outside of IE 9
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 30 Mar 2020 18:15:09 +0000 (20:15 +0200)
committerGitHub <noreply@github.com>
Mon, 30 Mar 2020 18:15:09 +0000 (20:15 +0200)
Closes gh-4647

src/manipulation/support.js
src/manipulation/wrapMap.js
test/unit/support.js

index 4a5d9af4ccaf1f5f8f0bdf0416ed23bf1baa6ca4..62d6bb3e059339b3ba383087e6c900f6e1cd35c9 100644 (file)
@@ -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;
index 1f446f7d73648fa8e75f9f9d69382e49ab153e58..da48bf9fedb103cc030719e6645d89c2f379a22f 100644 (file)
@@ -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;
 } );
index e293c742365b91786beb763368e07fa12c3d4041..dde4e41972617082b37ffc65f21063219cf369b6 100644 (file)
@@ -68,6 +68,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -86,6 +87,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": true,
                                "noCloneChecked": false,
+                               "option": true,
                                "optSelected": false,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -104,6 +106,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": true,
                                "noCloneChecked": false,
+                               "option": false,
                                "optSelected": false,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -122,6 +125,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -140,6 +144,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -158,6 +163,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": false,
                                "pixelPosition": false,
@@ -176,6 +182,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -194,6 +201,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -212,6 +220,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": true,
                                "pixelPosition": true,
@@ -230,6 +239,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": false,
                                "pixelPosition": false,
@@ -248,6 +258,7 @@ testIframe(
                                "createHTMLDocument": false,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": false,
                                "pixelPosition": false,
@@ -266,6 +277,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": false,
                                "pixelPosition": false,
@@ -284,6 +296,7 @@ testIframe(
                                "createHTMLDocument": true,
                                "focusin": false,
                                "noCloneChecked": true,
+                               "option": true,
                                "optSelected": true,
                                "pixelBoxStyles": false,
                                "pixelPosition": false,