var parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
- if ( value == null ) {
+ if ( value === undefined ) {
var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
- if ( data == undefined && this.length )
+ if ( data === undefined && this.length )
data = jQuery.data( this[0], key );
- return data == null && parts[1] ?
+ return data === undefined && parts[1] ?
this.data( parts[0] ) :
data;
} else
});\r
\r
test(".data()", function() {\r
- expect(16);\r
+ expect(18);\r
var div = $("#foo");\r
ok( div.data("test") == undefined, "Check for no data exists" );\r
div.data("test", "success");\r
ok( div.data("test") == "success", "Check for added data" );\r
div.data("test", "overwritten");\r
ok( div.data("test") == "overwritten", "Check for overwritten data" );\r
-\r
+ div.data("test", undefined);\r
+ ok( div.data("test") == "overwritten", "Check that data wasn't removed");\r
+ div.data("test", null);\r
+ ok( div.data("test") === null, "Check for null data");\r
+ \r
+ div.data("test", "overwritten");\r
var hits = {test:0}, gets = {test:0};\r
-\r
+ \r
div\r
.bind("setData",function(e,key,value){ hits[key] += value; })\r
.bind("setData.foo",function(e,key,value){ hits[key] += value; })\r