Fix #14101: $().data() should be undefined, not null

This commit is contained in:
Corey Frang 2013-11-05 15:03:28 -05:00 committed by Rick Waldron
parent cc19a6bd3b
commit 30eee925db
2 changed files with 7 additions and 2 deletions

View File

@ -75,8 +75,7 @@ jQuery.extend({
jQuery.fn.extend({
data: function( key, value ) {
var i, name,
data = null,
var i, name, data,
elem = this[ 0 ],
attrs = elem && elem.attributes;

View File

@ -170,6 +170,12 @@ test("jQuery.data(object/flash)", 25, function() {
dataTests( flash );
});
// attempting to access the data of an undefined jQuery element should be undefined
test("jQuery().data() === undefined (#14101)", 2, function() {
strictEqual(jQuery().data(), undefined);
strictEqual(jQuery().data("key"), undefined);
});
test(".data()", function() {
expect(5);