Add a feature test for options inside a disabled select. Follow-up to 157a383dae.

This commit is contained in:
jeresig 2010-09-27 10:19:55 -04:00
parent a384d840d6
commit 97d468fbf0
2 changed files with 12 additions and 2 deletions

View File

@ -164,8 +164,9 @@ jQuery.fn.extend({
var option = options[ i ]; var option = options[ i ];
// Don't return options that are disabled or in a disabled optgroup // Don't return options that are disabled or in a disabled optgroup
if ( option.selected && option.getAttribute("disabled") === null && if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
// Get the specific value for the option // Get the specific value for the option
value = jQuery(option).val(); value = jQuery(option).val();

View File

@ -20,6 +20,9 @@
return; return;
} }
var select = document.createElement("select");
var opt = select.appendChild( document.createElement("option") );
jQuery.support = { jQuery.support = {
// IE strips leading whitespace when .innerHTML is used // IE strips leading whitespace when .innerHTML is used
leadingWhitespace: div.firstChild.nodeType === 3, leadingWhitespace: div.firstChild.nodeType === 3,
@ -56,15 +59,21 @@
// Make sure that a selected-by-default option has a working selected property. // 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) // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, optSelected: opt.selected,
// Will be defined later // Will be defined later
optDisabled: false,
checkClone: false, checkClone: false,
scriptEval: false, scriptEval: false,
noCloneEvent: true, noCloneEvent: true,
boxModel: null 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"; script.type = "text/javascript";
try { try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); script.appendChild( document.createTextNode( "window." + id + "=1;" ) );