Skip to content
Permalink
Browse files

core: Fixed #2605: .data() now accepts null as a value.

  • Loading branch information
scottgonzalez committed May 3, 2008
1 parent 35c68b4 commit ad3c49d1b664d282b1e38b2012a0818f0595d2a5
Showing with 6 additions and 2 deletions.
  1. +1 −1 src/core.js
  2. +5 −1 test/unit/core.js
@@ -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() {

0 comments on commit ad3c49d

Please sign in to comment.
You can’t perform that action at this time.