Opened 13 years ago
Closed 13 years ago
#6556 closed bug (fixed)
.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).
Change History (5)
comment:1 Changed 13 years ago by
comment:5 Changed 13 years ago by
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' );