Bug Tracker

Opened 14 years ago

Closed 11 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:


Attachments (2)

test-2287-main.html (492 bytes) - added by dmethvin 12 years ago.
main file
test-2287-iframe.html (263 bytes) - added by dmethvin 12 years ago.
iframe contents

Download all attachments as: .zip

Change History (6)

comment:1 Changed 14 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 12 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.

Changed 12 years ago by dmethvin

Attachment: test-2287-main.html added

main file

Changed 12 years ago by dmethvin

Attachment: test-2287-iframe.html added

iframe contents

comment:3 Changed 12 years ago by SlexAxton

Priority: minorlow
Status: newopen

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

comment:4 Changed 11 years ago by dmethvin

Resolution: invalid
Status: openclosed

We never got a failing test case.

Note: See TracTickets for help on using tickets.