Side navigation
#6556 closed bug (fixed)
Opened May 10, 2010 09:07PM UTC
Closed October 17, 2010 11:21PM UTC
.data(object) breaks event handling
Reported by: | jaredjacobs | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | event | Version: | 1.4.2 |
Keywords: | data, event handler, handle | Cc: | |
Blocked by: | Blocking: |
Description
Calling .data({...}) results in a JS exception in jQuery.event.handle whenever a previously bound event handler is fired.
The documentation for .data() says: "Until jQuery 1.4.2, jQuery itself used the .data() method to save information about events that have been bound to the element, using a data item named 'events'."
There is unfortunately still some code in jQuery 1.4.2 that assumes that there is data about event bindings stashed in .data("events"). For example, this line from jQuery.event.handle is the one I'm seeing blow up:
var events = jQuery.data(this, "events"), handlers = events[ event.type ];
A quick search for the JS string "events" turns up two other similar sites: one in liveHandler (non-fatal) and one in jQuery.event.special.live.remove (probably fatal).
Attachments (0)
Change History (5)
Changed May 10, 2010 09:13PM UTC by comment:1
Changed May 10, 2010 09:16PM UTC by comment:2
_comment0: | Workaround, of course, is to call .data(k1: v1).data(k2: v2)... → 1287253270453041 |
---|
Workaround, of course, is to call .data(k1, v1).data(k2, v2)...
Changed October 16, 2010 04:18PM UTC by comment:3
This seems to be fixed in 1.4.3
Changed October 16, 2010 06:23PM UTC by comment:4
agreed. thanks team!
Changed October 17, 2010 11:21PM UTC by comment:5
priority: | → undecided |
---|---|
resolution: | → fixed |
status: | new → closed |
Here's an example that triggers the problem. It was posted in the jQuery.data comments 3 months ago.
http://api.jquery.com/data/#comment-30025031
$('<div>click me</div>').click( function(){alert('where?')} ).data( {key: 'val'} ).appendTo( 'body' );