Bug Tracker

Opened 8 years ago

Closed 5 years ago

#2287 closed bug (invalid)

Remove unnecessary sourcing of events from global window

Reported by: diego Owned by:
Priority: low Milestone:
Component: event Version: 1.2.2
Keywords: IE global event Cc:
Blocked by: Blocking:


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:


Change History (4)

comment:1 Changed 8 years 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.


comment:2 Changed 6 years ago by dmethvin

Can someone provide a test case? It seems plausible that the parent's window.event is the wrong one for an event fired from a child iframe, but i was unable to craft a test case that showed it failing. However, I'm leaving this ticket open and attaching my (working in IE8) test case as a starting point; this problem could be related to some of the other open iframe tickets.

comment:3 Changed 6 years ago by SlexAxton

  • Milestone changed from 1.2.3 to 1.5
  • Priority changed from minor to low
  • Status changed from new to open

I'm guessing your recent additions mean that we should open this one back up for a newer version. Acting.

comment:4 Changed 5 years ago by dmethvin

  • Resolution set to invalid
  • Status changed from open to closed

We never got a failing test case.

Note: See TracTickets for help on using tickets.