// 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;
};
} else if ( !cache[ id ] ) {
if ( isNode ) {
cache[ id ] = {};
+
} else {
store = {};
cache[ id ] = 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" );
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 );
});
test(".data()", function() {
- expect(1);
+ expect(2);
var div = jQuery("#foo");
div.data("test", "success");