jQuery.cache[ id ] = {};
// Prevent overriding the named cache with undefined values
- if ( data != undefined )
+ if ( data !== undefined )
jQuery.cache[ id ][ name ] = data;
// Return the named cache data, or the ID for the element
});\r
\r
test("$.data", function() {\r
- expect(3);\r
+ expect(5);\r
var div = $("#foo")[0];\r
ok( jQuery.data(div, "test") == undefined, "Check for no data exists" );\r
jQuery.data(div, "test", "success");\r
ok( jQuery.data(div, "test") == "success", "Check for added data" );\r
jQuery.data(div, "test", "overwritten");\r
ok( jQuery.data(div, "test") == "overwritten", "Check for overwritten data" );\r
+ jQuery.data(div, "test", undefined);\r
+ ok( jQuery.data(div, "test") == "overwritten", "Check that data wasn't removed");\r
+ jQuery.data(div, "test", null);\r
+ ok( jQuery.data(div, "test") === null, "Check for null data");\r
});\r
\r
test(".data()", function() {\r