Skip to main content

Bug Tracker

Side navigation

#7524 closed bug (fixed)

Opened November 15, 2010 05:22PM UTC

Closed December 06, 2010 10:24PM UTC

Calling $.fn.data without arguments on a non-DOMelement in 1.4.4

Reported by: timmolendijk Owned by: snover
Priority: blocker Milestone: 1.5
Component: data Version: 1.4.4
Keywords: regression Cc:
Blocked by: Blocking:
Description

Try the following code in 1.4.3 and then in 1.4.4:

$({tim: 28}).data()

In 1.4.3 the expected data object is returned, in 1.4.4 a TypeError in thrown: "Cannot read property 'length' of undefined"

The problem is in line 1250, in which it is assumed that the data object has an "attributes" property (which is obviously a valid assumption for DOM nodes with nodeType 1 but not for many other object types).

Attachments (0)
Change History (10)

Changed November 15, 2010 06:36PM UTC by boushley comment:1

_comment0: Here's a simple jsFiddle for this use case.1289846211031375

Here's a simple jsFiddle for this use case http://jsfiddle.net/boushley/CCdtM/.

Changed November 15, 2010 07:28PM UTC by rwaldron comment:2

resolution: → duplicate
status: newclosed

Confirmed

Changed November 15, 2010 07:31PM UTC by rwaldron comment:3

component: unfileddata
priority: undecidedlow
resolution: duplicate
status: closedreopened

Changed November 15, 2010 07:31PM UTC by rwaldron comment:4

milestone: 1.51.4.5

Changed November 16, 2010 01:34AM UTC by snover comment:5

_comment0: Calling $.fn.data on a plain JS object will just return the JS object. Is there actually a use case here?1289871318715733

Calling $.fn.data on a plain JS object with no argument will just return the JS object. Is there actually a use case here?

Changed November 16, 2010 12:43PM UTC by timmolendijk comment:6

Use case; sometimes it's a custom (not necessarily plain) JS object, sometimes it's a DOM element. That's where the $.data API shines, as you can just treat them all the same. This bug messes up this unity.

Changed November 22, 2010 06:24AM UTC by snover comment:7

keywords: → regression
priority: lowblocker
status: reopenedopen

I wish, I wish, I wish this wasn’t a regression.

Changed December 03, 2010 08:23AM UTC by snover comment:8

owner: → snover
status: openassigned

Changed December 06, 2010 10:24PM UTC by john comment:9

resolution: → fixed
status: assignedclosed

Landed.

Changed January 14, 2011 10:20PM UTC by jitter comment:10

milestone: 1.4.51.5

Move fixed tickets to appropriate milestone