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
b2ea79c4
Commit
b2ea79c4
authored
Dec 09, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'attrFollowupFix' of
https://github.com/jitter/jquery
into jitter-attrFollowupFix
parents
a13089d5
cc9dbd06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
attributes.js
src/attributes.js
+2
-2
attributes.js
test/unit/attributes.js
+4
-4
No files found.
src/attributes.js
View file @
b2ea79c4
...
...
@@ -272,8 +272,8 @@ jQuery.extend({
},
attr
:
function
(
elem
,
name
,
value
,
pass
)
{
// don't
set attributes on text and comment
nodes
if
(
!
elem
||
elem
.
nodeType
===
3
||
elem
.
nodeType
===
8
)
{
// don't
get/set attributes on text, comment and attribute
nodes
if
(
!
elem
||
elem
.
nodeType
===
3
||
elem
.
nodeType
===
8
||
elem
.
nodeType
===
2
)
{
return
undefined
;
}
...
...
test/unit/attributes.js
View file @
b2ea79c4
...
...
@@ -171,12 +171,12 @@ test("attr(String, Object)", function() {
commentNode
=
document
.
createComment
(
"some comment"
),
textNode
=
document
.
createTextNode
(
"some text"
),
obj
=
{};
jQuery
.
each
(
[
document
,
attributeNode
,
obj
,
"#firstp"
],
function
(
i
,
ele
)
{
jQuery
.
each
(
[
document
,
obj
,
"#firstp"
],
function
(
i
,
ele
)
{
var
$ele
=
jQuery
(
ele
);
$ele
.
attr
(
"nonexisting"
,
"foo"
);
equal
(
$ele
.
attr
(
"nonexisting"
),
"foo"
,
"attr(name, value) works correctly for non existing attributes (bug #7500)."
);
});
jQuery
.
each
(
[
commentNode
,
textNode
],
function
(
i
,
ele
)
{
jQuery
.
each
(
[
commentNode
,
textNode
,
attributeNode
],
function
(
i
,
ele
)
{
var
$ele
=
jQuery
(
ele
);
$ele
.
attr
(
"nonexisting"
,
"foo"
);
strictEqual
(
$ele
.
attr
(
"nonexisting"
),
undefined
,
"attr(name, value) works correctly on comment and text nodes (bug #7500)."
);
...
...
@@ -366,12 +366,12 @@ test("removeAttr(String)", function() {
//removeAttr only really removes on DOM element nodes handle all other seperatyl
strictEqual
(
jQuery
(
"#firstp"
).
attr
(
"nonexisting"
,
"foo"
).
removeAttr
(
"nonexisting"
)[
0
].
nonexisting
,
undefined
,
"removeAttr works correctly on DOM element nodes"
);
jQuery
.
each
(
[
document
,
attributeNode
,
obj
],
function
(
i
,
ele
)
{
jQuery
.
each
(
[
document
,
obj
],
function
(
i
,
ele
)
{
var
$ele
=
jQuery
(
ele
);
$ele
.
attr
(
"nonexisting"
,
"foo"
).
removeAttr
(
"nonexisting"
);
strictEqual
(
ele
.
nonexisting
,
""
,
"removeAttr works correctly on non DOM element nodes (bug #7500)."
);
});
jQuery
.
each
(
[
commentNode
,
textNode
],
function
(
i
,
ele
)
{
jQuery
.
each
(
[
commentNode
,
textNode
,
attributeNode
],
function
(
i
,
ele
)
{
$ele
=
jQuery
(
ele
);
$ele
.
attr
(
"nonexisting"
,
"foo"
).
removeAttr
(
"nonexisting"
);
strictEqual
(
ele
.
nonexisting
,
undefined
,
"removeAttr works correctly on non DOM element nodes (bug #7500)."
);
...
...
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