aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes.js
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2009-12-22 15:02:52 -0500
committerjeresig <jeresig@gmail.com>2009-12-22 15:02:52 -0500
commit4729f4d44326fd302c63af8f3324b6c4bac54084 (patch)
treeb867e1c44f020308c1e5353678e75fc4ef357aa0 /src/attributes.js
parentbaff0b0c852d37c1fdcb16167f27c0c589289960 (diff)
downloadjquery-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.js11
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