Bug Tracker

Modify

Ticket #6166 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed
  • Version changed from 1.4.1 to 1.4.2
  • Component changed from unfiled to data
  • Milestone changed from 1.4.2 to 1.4.3

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.