aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/data.js6
-rw-r--r--test/unit/data.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/data.js b/src/data.js
index b7a6ab972..ac082dd6e 100644
--- a/src/data.js
+++ b/src/data.js
@@ -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() {
diff --git a/test/unit/data.js b/test/unit/data.js
index 54a89d920..1163ddc29 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -25,7 +25,7 @@ test("expando", function(){
});
test("jQuery.data", function() {
- expect(12);
+ expect(13);
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");