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
25118e22
Commit
25118e22
authored
May 18, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle unset value attributes consistently depending on property existence. Supplements #9328.
parent
ba90af0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
attributes.js
src/attributes.js
+4
-3
attributes.js
test/unit/attributes.js
+3
-1
No files found.
src/attributes.js
View file @
25118e22
...
...
@@ -343,8 +343,8 @@ jQuery.extend({
return
value
;
}
}
else
if
(
hooks
&&
"get"
in
hooks
&&
notxml
)
{
return
hooks
.
get
(
elem
,
name
)
;
}
else
if
(
hooks
&&
"get"
in
hooks
&&
notxml
&&
(
ret
=
hooks
.
get
(
elem
,
name
))
!==
null
)
{
return
ret
;
}
else
{
...
...
@@ -495,12 +495,13 @@ boolHook = {
// Use the formHook for button elements in IE6/7 (#1954)
jQuery
.
attrHooks
.
value
=
{
get
:
function
(
elem
,
name
)
{
var
ret
;
if
(
formHook
&&
jQuery
.
nodeName
(
elem
,
"button"
)
)
{
return
formHook
.
get
(
elem
,
name
);
}
return
name
in
elem
?
elem
.
value
:
elem
.
getAttribute
(
name
)
;
null
;
},
set
:
function
(
elem
,
value
,
name
)
{
if
(
formHook
&&
jQuery
.
nodeName
(
elem
,
"button"
)
)
{
...
...
test/unit/attributes.js
View file @
25118e22
...
...
@@ -40,7 +40,7 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() {
});
test
(
"attr(String)"
,
function
()
{
expect
(
4
3
);
expect
(
4
5
);
equals
(
jQuery
(
"#text1"
).
attr
(
"type"
),
"text"
,
"Check for type attribute"
);
equals
(
jQuery
(
"#radio1"
).
attr
(
"type"
),
"radio"
,
"Check for type attribute"
);
...
...
@@ -126,6 +126,8 @@ test("attr(String)", function() {
ok
(
jQuery
(
"<div/>"
).
attr
(
"title"
)
===
undefined
,
"Make sure undefined is returned when no attribute is found."
);
equal
(
jQuery
(
"<div/>"
).
attr
(
"title"
,
"something"
).
attr
(
"title"
),
"something"
,
"Set the title attribute."
);
ok
(
jQuery
().
attr
(
"doesntexist"
)
===
undefined
,
"Make sure undefined is returned when no element is there."
);
equal
(
jQuery
(
"<div/>"
).
attr
(
"value"
),
undefined
,
"An unset value on a div returns undefined."
);
equal
(
jQuery
(
"<input/>"
).
attr
(
"value"
),
""
,
"An unset value on an input returns current value."
);
});
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