Ticket #10717 (closed bug: fixed)
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:
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 19 months 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
comment:2 Changed 19 months 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.

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.