Ticket #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: | |
| Blocking: | Blocked by: |
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Fixed. http://github.com/jquery/jquery/commit/9e06903a99caf5619d0db858ed3d24f0e6ee15db