Bug Tracker

Modify

Ticket #6259 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

data() returns null, but undefined in Firefox after console.log()

Reported by: pjdietz Owned by:
Priority: Milestone: 1.4.3
Component: data Version: 1.4.2
Keywords: data firefox console null undefined Cc:
Blocking: Blocked by:

Description

I noticed that in 1.4, data() now returns null instead of undefined if nothing has been set for a given key. However, in Firefox 3.6 (Mac and Win), passing an object to console.log() first, then trying to retrieve data for a non-existent key yields undefined (as was the behavior in jQuery 1.3).

Not sure if this is a Firebug problem more than a jQuery problem, but I thought it was worth looking into.

I tried this in Safari and Chrome on Mac and got null before and after the conole.log() call.

Here's some sample code I used to test this:

$(document).ready(function () {

var myElement, myData;

myElement = $("#MyElement");

myData = myElement.data("myKey"); console.log(myData); null

console.log(myElement);

myData = myElement.data("myKey"); console.log(myData); undefined

});

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to duplicate
  • Component changed from core to data

This is a duplicate of #6166.

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.