]> source.dussan.org Git - jquery.git/commitdiff
core: Fixed #2605: .data() now accepts null as a value.
authorScott González <scott.gonzalez@gmail.com>
Sat, 3 May 2008 01:39:27 +0000 (01:39 +0000)
committerScott González <scott.gonzalez@gmail.com>
Sat, 3 May 2008 01:39:27 +0000 (01:39 +0000)
src/core.js
test/unit/core.js

index c3cd3d8e3ccf93a3a3a926cf0bda597280287f3e..b6bdc1d0c94f6031554b10b5647bfe03a724c283 100644 (file)
@@ -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       
index 7ec825832106cedb2cc631c30a8a15e7feaa78a5..e6321a6436bf385249b8318228314c9a98a80f30 100644 (file)
@@ -1398,13 +1398,17 @@ test("$.className", function() {
 });\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