Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#6163 closed bug (fixed)

TypeError: events is null

Reported by: mike.helgeson Owned by: brandon
Priority: Milestone: 1.4.3
Component: event Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:

Description

When attempting to "handle" any events on an element that has no events bound to it, the handle function generates this exception. This is a simple fix. The handle function reads the "events" data for the element, then looks up the "handlers" for the given event type. In the case where events have never been bound, the "events" data is null and trying to read the handlers from null is creating the error.

The fix is on line 1919 of jQuery 1.4.2...

Change this:

handlers = events[ event.type ]

To this:

handlers = ( events || {} )[ event.type ]

The justification for this is any plugin that uses event publishing may cause event handling on elements where no events have been bound.

Sample page showing the error:

http://jsbin.com/oforu

Change History (3)

comment:1 Changed 13 years ago by brandon

Owner: set to brandon

comment:2 Changed 13 years ago by brandon

Milestone: 1.4.21.4.3

comment:3 Changed 13 years ago by brandon

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.