Make sure that undefined is always returned for missing data properties. Follow-up to #6304.
This commit is contained in:
parent
76db8a9822
commit
515efbdc71
1 changed files with 4 additions and 1 deletions
|
@ -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" );
|
||||||
|
|
Loading…
Add table
Reference in a new issue