Bug Tracker

Modify

Ticket #10717 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

A triggered load bubbles up to window

Reported by: Boldewyn Owned by: dmethvin
Priority: low Milestone: 1.7.1
Component: event Version: 1.7
Keywords: Cc:
Blocking: Blocked by:

Description

Consider this JSFiddle:

 http://jsfiddle.net/Ytzd9/

A function is bound via $(window).load(). Then the load event is triggered on an external resource element (in this case an image):

$('img#foo').trigger(load);

  • Actual output:

The load event bubbles up from the image to the window object.

  • Expected output:

The event should not bubble. Native load events on images, iframes, ... don't bubble to the parent window, too.

Change History

comment:1 Changed 2 years ago by dmethvin

  • Owner set to dmethvin
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to event
  • Milestone changed from None to 1.7.1

This was introduced in 1.5 as a consequence of events now bubbling to window (as the W3C Events Level 3 spec says they should). However, you're right that the load event isn't supposed to bubble *at all*; a browser event doesn't but our triggered event does. That's easily fixable in 1.7.1 with the new special events hooks.

comment:2 Changed 2 years ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Fix #10717, .trigger("load") on images can't bubble to window.

This means no manually triggered event named "load" can bubble, so avoid that name for delegated custom events.

Changeset: 45101de6962186a21bc557d1c55ec4844dfb241e

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.