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
d36d224c
Commit
d36d224c
authored
Jul 16, 2009
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented .data() to get the entire data object. Closes #4284
parent
8e54b167
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
data.js
src/data.js
+4
-0
data.js
test/unit/data.js
+8
-0
No files found.
src/data.js
View file @
d36d224c
...
@@ -23,6 +23,8 @@ jQuery.extend({
...
@@ -23,6 +23,8 @@ jQuery.extend({
if
(
data
!==
undefined
)
if
(
data
!==
undefined
)
jQuery
.
cache
[
id
][
name
]
=
data
;
jQuery
.
cache
[
id
][
name
]
=
data
;
if
(
name
===
true
)
return
jQuery
.
cache
[
id
]
// Return the named cache data, or the ID for the element
// Return the named cache data, or the ID for the element
return
name
?
return
name
?
jQuery
.
cache
[
id
][
name
]
:
jQuery
.
cache
[
id
][
name
]
:
...
@@ -98,6 +100,8 @@ jQuery.extend({
...
@@ -98,6 +100,8 @@ jQuery.extend({
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
data
:
function
(
key
,
value
){
data
:
function
(
key
,
value
){
if
(
typeof
key
===
"undefined"
&&
this
.
length
)
return
jQuery
.
data
(
this
[
0
],
true
);
var
parts
=
key
.
split
(
"."
);
var
parts
=
key
.
split
(
"."
);
parts
[
1
]
=
parts
[
1
]
?
"."
+
parts
[
1
]
:
""
;
parts
[
1
]
=
parts
[
1
]
?
"."
+
parts
[
1
]
:
""
;
...
...
test/unit/data.js
View file @
d36d224c
...
@@ -15,6 +15,14 @@ test("jQuery.data", function() {
...
@@ -15,6 +15,14 @@ test("jQuery.data", function() {
});
});
test
(
".data()"
,
function
()
{
test
(
".data()"
,
function
()
{
expect
(
1
);
var
div
=
jQuery
(
"#foo"
);
div
.
data
(
"test"
,
"success"
);
isObj
(
div
.
data
(),
{
test
:
"success"
},
"data() get the entire data object"
)
})
test
(
".data(String) and .data(String, Object)"
,
function
()
{
expect
(
22
);
expect
(
22
);
var
div
=
jQuery
(
"#foo"
);
var
div
=
jQuery
(
"#foo"
);
equals
(
div
.
data
(
"test"
),
undefined
,
"Check for no data exists"
);
equals
(
div
.
data
(
"test"
),
undefined
,
"Check for no data exists"
);
...
...
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