X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fattributes.js;h=a2108feb85c71320b0b9c7ee98a89478302c9845;hb=0645b71ee6139c19c2c5a488f16f50dc1c31e9ac;hp=d3afa89ec0766e99795b4a514afef661612d5554;hpb=e87b090cb706b495b6c48e960d6c059c7fbddbd9;p=jquery.git diff --git a/src/attributes.js b/src/attributes.js index d3afa89..a2108fe 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -263,10 +263,18 @@ jQuery.extend({ // These attributes require special treatment var special = rspecialurl.test( name ); - // Safari mis-reports the default selected property of a hidden option + // Safari mis-reports the default selected property of an option // Accessing the parent's selectedIndex property fixes it - if ( name === "selected" && elem.parentNode ) { - elem.parentNode.selectedIndex; + if ( name === "selected" && !jQuery.support.optSelected ) { + var parent = elem.parentNode; + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } } // If applicable, access the attribute via the DOM 0 way