Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
4729f4d4
Commit
4729f4d4
authored
Dec 22, 2009
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that selected works in Safari on options in optgroups. Fixes #5701.
parent
baff0b0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
attributes.js
src/attributes.js
+8
-3
attributes.js
test/unit/attributes.js
+7
-1
No files found.
src/attributes.js
View file @
4729f4d4
...
@@ -261,12 +261,17 @@ jQuery.extend({
...
@@ -261,12 +261,17 @@ jQuery.extend({
// Only do all the following if this is a node (faster for style)
// Only do all the following if this is a node (faster for style)
if
(
elem
.
nodeType
===
1
)
{
if
(
elem
.
nodeType
===
1
)
{
// These attributes require special treatment
// 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
// Safari mis-reports the default selected property of a hidden option
// Accessing the parent's selectedIndex property fixes it
// Accessing the parent's selectedIndex property fixes it
if
(
name
===
"selected"
&&
elem
.
parentNode
)
{
if
(
name
===
"selected"
&&
parent
)
{
elem
.
parentNode
.
selectedIndex
;
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
// If applicable, access the attribute via the DOM 0 way
...
...
test/unit/attributes.js
View file @
4729f4d4
...
@@ -4,7 +4,7 @@ var bareObj = function(value) { return value; };
...
@@ -4,7 +4,7 @@ var bareObj = function(value) { return value; };
var
functionReturningObj
=
function
(
value
)
{
return
(
function
()
{
return
value
;
});
};
var
functionReturningObj
=
function
(
value
)
{
return
(
function
()
{
return
value
;
});
};
test
(
"attr(String)"
,
function
()
{
test
(
"attr(String)"
,
function
()
{
expect
(
2
7
);
expect
(
2
8
);
// This one sometimes fails randomly ?!
// This one sometimes fails randomly ?!
equals
(
jQuery
(
'#text1'
).
attr
(
'value'
),
"Test"
,
'Check for value attribute'
);
equals
(
jQuery
(
'#text1'
).
attr
(
'value'
),
"Test"
,
'Check for value attribute'
);
...
@@ -55,6 +55,12 @@ test("attr(String)", function() {
...
@@ -55,6 +55,12 @@ test("attr(String)", function() {
ok
(
$body
.
attr
(
'foo'
)
===
undefined
,
'Make sure the expando is preferred over the dom attribute, even if undefined'
);
ok
(
$body
.
attr
(
'foo'
)
===
undefined
,
'Make sure the expando is preferred over the dom attribute, even if undefined'
);
body
.
removeAttribute
(
'foo'
);
// Cleanup
body
.
removeAttribute
(
'foo'
);
// Cleanup
var
select
=
document
.
createElement
(
"select"
),
optgroup
=
document
.
createElement
(
"optgroup"
),
option
=
document
.
createElement
(
"option"
);
optgroup
.
appendChild
(
option
);
select
.
appendChild
(
optgroup
);
equals
(
jQuery
(
option
).
attr
(
"selected"
),
true
,
"Make sure that a single option is selected, even when in an optgroup."
);
});
});
if
(
!
isLocal
)
{
if
(
!
isLocal
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment