Add a feature test for options inside a disabled select. Follow-up to 157a383dae5335e...
[jquery.git] / src / support.js
index c9ff58c..2015918 100644 (file)
@@ -1,3 +1,5 @@
+(function( jQuery ) {
+
 (function() {
 
        jQuery.support = {};
@@ -5,7 +7,7 @@
        var root = document.documentElement,
                script = document.createElement("script"),
                div = document.createElement("div"),
-               id = "script" + now();
+               id = "script" + jQuery.now();
 
        div.style.display = "none";
        div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
@@ -18,6 +20,9 @@
                return;
        }
 
+       var select = document.createElement("select");
+       var opt = select.appendChild( document.createElement("option") );
+
        jQuery.support = {
                // IE strips leading whitespace when .innerHTML is used
                leadingWhitespace: div.firstChild.nodeType === 3,
 
                // Make sure that a selected-by-default option has a working selected property.
                // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
-               optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
-
-               parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,
+               optSelected: opt.selected,
 
                // Will be defined later
+               optDisabled: false,
                checkClone: false,
                scriptEval: false,
                noCloneEvent: true,
                boxModel: null
        };
 
+       // Make sure that the options inside disabled selects aren't marked as disabled
+       // (WebKit marks them as diabled)
+       select.disabled = true;
+       jQuery.support.optDisabled = !opt.disabled;
+
        script.type = "text/javascript";
        try {
                script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
@@ -148,3 +157,5 @@ jQuery.props = {
        usemap: "useMap",
        frameborder: "frameBorder"
 };
+
+})( jQuery );