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
06f46dad
Commit
06f46dad
authored
Dec 16, 2012
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
let .attr(checked|selected, true) update the property
parent
30e2ffbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
attributes.js
src/attributes.js
+1
-1
attributes.js
test/unit/attributes.js
+9
-2
No files found.
src/attributes.js
View file @
06f46dad
...
...
@@ -489,7 +489,7 @@ boolHook = {
// Use defaultChecked and defaultSelected for oldIE
}
else
{
elem
[
jQuery
.
camelCase
(
"default-"
+
name
)
]
=
true
;
elem
[
jQuery
.
camelCase
(
"default-"
+
name
)
]
=
elem
[
name
]
=
true
;
}
return
name
;
...
...
test/unit/attributes.js
View file @
06f46dad
...
...
@@ -247,7 +247,7 @@ test( "attr(Hash)", function() {
});
test
(
"attr(String, Object)"
,
function
()
{
expect
(
67
);
expect
(
71
);
var
div
=
jQuery
(
"div"
).
attr
(
"foo"
,
"bar"
),
i
=
0
,
...
...
@@ -281,7 +281,14 @@ test( "attr(String, Object)", function() {
equal
(
$input
.
attr
(
"name"
),
"something"
,
"Check element creation gets/sets the name attribute."
);
equal
(
$input
.
attr
(
"id"
),
"specified"
,
"Check element creation gets/sets the id attribute."
);
// As of fixing #11115, we make no promises about the effect of .attr on boolean properties
// As of fixing #11115, we only guarantee boolean property update for checked and selected
$input
=
jQuery
(
"<input type='checkbox'/>"
).
attr
(
"checked"
,
true
);
equal
(
$input
.
prop
(
"checked"
),
true
,
"Setting checked updates property (verified by .prop)"
);
equal
(
$input
[
0
].
checked
,
true
,
"Setting checked updates property (verified by native property)"
);
$input
=
jQuery
(
"<option/>"
).
attr
(
"selected"
,
true
);
equal
(
$input
.
prop
(
"selected"
),
true
,
"Setting selected updates property (verified by .prop)"
);
equal
(
$input
[
0
].
selected
,
true
,
"Setting selected updates property (verified by native property)"
);
$input
=
jQuery
(
"#check2"
);
$input
.
prop
(
"checked"
,
true
).
prop
(
"checked"
,
false
).
attr
(
"checked"
,
true
);
equal
(
$input
.
attr
(
"checked"
),
"checked"
,
"Set checked (verified by .attr)"
);
...
...
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