Opened 13 years ago
Closed 13 years ago
#7524 closed bug (fixed)
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).
Change History (10)
comment:4 Changed 13 years ago by
Component: | unfiled → data |
---|---|
Priority: | undecided → low |
Resolution: | duplicate |
Status: | closed → reopened |
comment:5 Changed 13 years ago by
Milestone: | 1.5 → 1.4.5 |
---|
comment:6 Changed 13 years ago by
Calling $.fn.data on a plain JS object with no argument will just return the JS object. Is there actually a use case here?
comment:7 Changed 13 years ago by
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.
comment:8 Changed 13 years ago by
Keywords: | regression added |
---|---|
Priority: | low → blocker |
Status: | reopened → open |
I wish, I wish, I wish this wasn’t a regression.
comment:11 Changed 13 years ago by
Milestone: | 1.4.5 → 1.5 |
---|
Move fixed tickets to appropriate milestone
Here's a simple jsFiddle for this use case http://jsfiddle.net/boushley/CCdtM/.