Skip to content

Commit

Permalink
Make sure that undefined is always returned for missing data properti…
Browse files Browse the repository at this point in the history
…es. Follow-up to #6304.
  • Loading branch information
jeresig committed Sep 24, 2010
1 parent 76db8a9 commit 515efbd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/unit/data.js
Expand Up @@ -81,11 +81,14 @@ test("jQuery.data", function() {
}); });


test(".data()", function() { test(".data()", function() {
expect(2); expect(4);


var div = jQuery("#foo"); var div = jQuery("#foo");
strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );

div.data("test", "success"); div.data("test", "success");
same( div.data(), {test: "success"}, "data() get the entire data object" ); same( div.data(), {test: "success"}, "data() get the entire data object" );
strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" );


var nodiv = jQuery("#unfound"); var nodiv = jQuery("#unfound");
equals( nodiv.data(), null, "data() on empty set returns null" ); equals( nodiv.data(), null, "data() on empty set returns null" );
Expand Down

0 comments on commit 515efbd

Please sign in to comment.