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
8943b427
Commit
8943b427
authored
Dec 06, 2010
by
John Resig
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug7524' of
https://github.com/csnover/jquery
into csnover-bug7524
parents
9759e9f6
11e52bda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
data.js
src/data.js
+9
-7
data.js
test/unit/data.js
+4
-1
No files found.
src/data.js
View file @
8943b427
...
...
@@ -138,15 +138,17 @@ jQuery.fn.extend({
if
(
typeof
key
===
"undefined"
)
{
if
(
this
.
length
)
{
var
attr
=
this
[
0
].
attributes
,
name
;
data
=
jQuery
.
data
(
this
[
0
]
);
for
(
var
i
=
0
,
l
=
attr
.
length
;
i
<
l
;
i
++
)
{
name
=
attr
[
i
].
name
;
if
(
name
.
indexOf
(
"data-"
)
===
0
)
{
name
=
name
.
substr
(
5
);
dataAttr
(
this
[
0
],
name
,
data
[
name
]
);
if
(
this
[
0
].
nodeType
===
1
)
{
var
attr
=
this
[
0
].
attributes
,
name
;
for
(
var
i
=
0
,
l
=
attr
.
length
;
i
<
l
;
i
++
)
{
name
=
attr
[
i
].
name
;
if
(
name
.
indexOf
(
"data-"
)
===
0
)
{
name
=
name
.
substr
(
5
);
dataAttr
(
this
[
0
],
name
,
data
[
name
]
);
}
}
}
}
...
...
test/unit/data.js
View file @
8943b427
...
...
@@ -79,7 +79,7 @@ test("jQuery.data", function() {
});
test
(
".data()"
,
function
()
{
expect
(
4
);
expect
(
5
);
var
div
=
jQuery
(
"#foo"
);
strictEqual
(
div
.
data
(
"foo"
),
undefined
,
"Make sure that missing result is undefined"
);
...
...
@@ -90,6 +90,9 @@ test(".data()", function() {
var
nodiv
=
jQuery
(
"#unfound"
);
equals
(
nodiv
.
data
(),
null
,
"data() on empty set returns null"
);
var
obj
=
{
foo
:
"bar"
};
equals
(
jQuery
(
obj
).
data
(),
obj
,
"Retrieve data object from a wrapped JS object (#7524)"
);
})
test
(
".data(String) and .data(String, Object)"
,
function
()
{
...
...
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