Only try to get data attributes for a jQuery-wrapped object if it is actually an Element node. Fixes #7524.

This commit is contained in:
Colin Snover 2010-12-03 01:19:39 -06:00
parent e1d6edf822
commit 11e52bdaea
2 changed files with 13 additions and 8 deletions

View file

@ -79,7 +79,7 @@ test("jQuery.data", function() {
});
test(".data()", function() {
expect(4);
expect(5);
var div = jQuery("#foo");
strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
@ -90,6 +90,9 @@ test(".data()", function() {
var nodiv = jQuery("#unfound");
equals( nodiv.data(), null, "data() on empty set returns null" );
var obj = { foo: "bar" };
equals( jQuery(obj).data(), obj, "Retrieve data object from a wrapped JS object (#7524)" );
})
test(".data(String) and .data(String, Object)", function() {