core: Fixed #2605: .data() now accepts null as a value.
This commit is contained in:
parent
35c68b4578
commit
ad3c49d1b6
|
@ -669,7 +669,7 @@ jQuery.extend({
|
|||
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
|
||||
|
|
|
@ -1398,13 +1398,17 @@ test("$.className", function() {
|
|||
});
|
||||
|
||||
test("$.data", function() {
|
||||
expect(3);
|
||||
expect(5);
|
||||
var div = $("#foo")[0];
|
||||
ok( jQuery.data(div, "test") == undefined, "Check for no data exists" );
|
||||
jQuery.data(div, "test", "success");
|
||||
ok( jQuery.data(div, "test") == "success", "Check for added data" );
|
||||
jQuery.data(div, "test", "overwritten");
|
||||
ok( jQuery.data(div, "test") == "overwritten", "Check for overwritten data" );
|
||||
jQuery.data(div, "test", undefined);
|
||||
ok( jQuery.data(div, "test") == "overwritten", "Check that data wasn't removed");
|
||||
jQuery.data(div, "test", null);
|
||||
ok( jQuery.data(div, "test") === null, "Check for null data");
|
||||
});
|
||||
|
||||
test(".data()", function() {
|
||||
|
|
Loading…
Reference in a new issue