Skip to content
Permalink
Browse files

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

  • Loading branch information
gnarf authored and rwaldron committed Nov 6, 2013
1 parent cc19a6b commit 30eee925dbc9f8d465ccf064f48c24061ffdc378
Showing with 7 additions and 2 deletions.
  1. +1 −2 src/data.js
  2. +6 −0 test/unit/data.js
@@ -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;

@@ -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);

0 comments on commit 30eee92

Please sign in to comment.
You can’t perform that action at this time.