Bug Tracker

Opened 10 years ago

Closed 10 years ago

#6166 closed bug (fixed)

typeof($(EXPR).data('undefinedKey')) returns object vs 'undefined' now

Reported by: scunliffe Owned by:
Priority: Milestone: 1.4.3
Component: data Version: 1.4.2
Keywords: data Cc:
Blocked by: Blocking:

Description

I could be wrong but I believe a behavior has changed from jQuery 1.4.1 to 1.4.2

I have code similar to this: if(typeof($('#someID').data('somekey')) == 'undefined'){

alert('1. NOT SET');

} else {

alert('2. IS SET');

}

In 1.4.1 (and previous) if the key wasn't set, the typeof test returned undefined (e.g. Alert #1)

In 1.4.2 I get into the else block, because the typeof is returning 'object'

Did I miss a key part of the 1.4.x upgrade notes? if it was changed on purpose, how does one tell if the "key" is not set yet?

Change History (1)

comment:1 Changed 10 years ago by john

Component: unfileddata
Milestone: 1.4.21.4.3
Resolution: fixed
Status: newclosed
Version: 1.4.11.4.2
Note: See TracTickets for help on using tickets.