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
0b4b3ee8
Commit
0b4b3ee8
authored
Sep 22, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make .data(Object) extend the existing data object. Fixes #6692.
parent
626624a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
data.js
src/data.js
+4
-2
data.js
test/unit/data.js
+4
-2
No files found.
src/data.js
View file @
0b4b3ee8
...
...
@@ -52,9 +52,10 @@ jQuery.extend({
// want to manipulate it.
if
(
typeof
name
===
"object"
)
{
if
(
isNode
)
{
cache
[
id
]
=
jQuery
.
extend
(
true
,
{},
name
);
cache
[
id
]
=
jQuery
.
extend
(
cache
[
id
],
name
);
}
else
{
store
=
jQuery
.
extend
(
true
,
{}
,
name
);
store
=
jQuery
.
extend
(
cache
[
id
]
,
name
);
cache
[
id
]
=
function
()
{
return
store
;
};
...
...
@@ -63,6 +64,7 @@ jQuery.extend({
}
else
if
(
!
cache
[
id
]
)
{
if
(
isNode
)
{
cache
[
id
]
=
{};
}
else
{
store
=
{};
cache
[
id
]
=
function
()
{
...
...
test/unit/data.js
View file @
0b4b3ee8
...
...
@@ -25,7 +25,7 @@ test("expando", function(){
});
test
(
"jQuery.data"
,
function
()
{
expect
(
1
2
);
expect
(
1
3
);
var
div
=
document
.
createElement
(
"div"
);
ok
(
jQuery
.
data
(
div
,
"test"
)
===
undefined
,
"Check for no data exists"
);
...
...
@@ -47,9 +47,11 @@ test("jQuery.data", function() {
jQuery
.
data
(
div
,
"test"
,
null
);
ok
(
jQuery
.
data
(
div
,
"test"
)
===
null
,
"Check for null data"
);
jQuery
.
data
(
div
,
"test3"
,
"orig"
);
jQuery
.
data
(
div
,
{
"test"
:
"in"
,
"test2"
:
"in2"
});
equals
(
jQuery
.
data
(
div
,
"test"
),
"in"
,
"Verify setting an object in data."
);
equals
(
jQuery
.
data
(
div
,
"test2"
),
"in2"
,
"Verify setting an object in data."
);
equals
(
jQuery
.
data
(
div
,
"test3"
),
"orig"
,
"Verify original not overwritten."
);
var
obj
=
{};
jQuery
.
data
(
obj
,
"prop"
,
true
);
...
...
@@ -61,7 +63,7 @@ test("jQuery.data", function() {
});
test
(
".data()"
,
function
()
{
expect
(
1
);
expect
(
2
);
var
div
=
jQuery
(
"#foo"
);
div
.
data
(
"test"
,
"success"
);
...
...
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