diff options
author | jeresig <jeresig@gmail.com> | 2009-12-22 15:02:52 -0500 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2009-12-22 15:02:52 -0500 |
commit | 4729f4d44326fd302c63af8f3324b6c4bac54084 (patch) | |
tree | b867e1c44f020308c1e5353678e75fc4ef357aa0 /src/attributes.js | |
parent | baff0b0c852d37c1fdcb16167f27c0c589289960 (diff) | |
download | jquery-4729f4d44326fd302c63af8f3324b6c4bac54084.tar.gz jquery-4729f4d44326fd302c63af8f3324b6c4bac54084.zip |
Make sure that selected works in Safari on options in optgroups. Fixes #5701.
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/attributes.js b/src/attributes.js index d3afa89ec..30b3205a1 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -261,12 +261,17 @@ jQuery.extend({ // Only do all the following if this is a node (faster for style) if ( elem.nodeType === 1 ) { // These attributes require special treatment - var special = rspecialurl.test( name ); + var special = rspecialurl.test( name ), parent = elem.parentNode; // Safari mis-reports the default selected property of a hidden option // Accessing the parent's selectedIndex property fixes it - if ( name === "selected" && elem.parentNode ) { - elem.parentNode.selectedIndex; + if ( name === "selected" && 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 |