Bug Tracker

Ticket #2287 (new bug)

Opened 7 months ago

Last modified 7 months ago

Remove unnecessary sourcing of events from global window

Reported by: diego Assigned to: anonymous
Type: bug Priority: minor
Milestone: 1.2.3 Component: event
Version: 1.2.2 Keywords: IE global event
Cc: Needs: Review

Description

This is only needed in multi-document environments like iframes, new window.open or created documents, where the window, source of the event, may be different each time.

For Internet Explorer jQuery uses attachEvent, so if attachEvent is really able to always pass a correctly sourced event we shouldn't need this (current jquery):

event = jQuery.event.fix( event || window.event || {} );

but this instead:

event = jQuery.event.fix( event );

If instead there are known cases where event may be "null" or "undefined" then the above line should be fixed as follow:

event = jQuery.event.fix( event || ((this.ownerDocument || this.document || this).parentWindow || window).event );

This is the related discussion on the "jquery-dev" group:

http://groups.google.com/group/jquery-dev/browse_thread/thread/b87638ba86f03fe5

Attachments

Change History

Changed 7 months ago by diego

An omission in the above, I forgot to include the empty event object for custom events.

The suggested fixes should be changed as follow instead.

This will work correctly, even for custom events:

event = jQuery.event.fix( event || {} );

In cases where the event object may be "null" or "undefined", probably in the case of triggered DOM0 events, we would have to use a longer conditional reference instead:

event = jQuery.event.fix( event ||
           ((this.ownerDocument ||
                  this.document ||
             this).parentWindow ||
                  window).event || {} );

This bug will only show if DOM0 events and/or iframes are used.

I retested and the bug will never show in a single document environment and will never fail when DOM2 events or IE attachEvent are used to setup the chains of event listeners.

Diego

Note: See TracTickets for help on using tickets.