Bug Tracker

Ticket #2287 (closed bug: invalid)

Opened 7 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

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

Change History

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

Diego

comment:2 Changed 4 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 4 years ago by dmethvin

main file

Changed 4 years ago by dmethvin

iframe contents

comment:3 Changed 4 years ago by SlexAxton

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

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

comment:4 Changed 4 years ago by dmethvin

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

We never got a failing test case.

Note: See TracTickets for help on using tickets.