jQuery.fn.extend({
data: function( key, value ) {
- var i, name,
- data = null,
+ var i, name, data,
elem = this[0],
attrs = elem && elem.attributes;
// Gets one value
// Try to fetch any internally stored data first
- elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
+ elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
},
removeData: function( key ) {
ok( !jQuery.acceptData( document.createTextNode("") ), "text" );
});
+// 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);