From 45101de6962186a21bc557d1c55ec4844dfb241e Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 8 Nov 2011 19:32:25 -0500 Subject: [PATCH] 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. --- src/event.js | 5 +++++ test/unit/event.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/event.js b/src/event.js index 7d0c516f5..ea2bfa982 100644 --- a/src/event.js +++ b/src/event.js @@ -566,6 +566,11 @@ jQuery.event = { setup: jQuery.bindReady }, + load: { + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + focus: { delegateType: "focusin", noBubble: true diff --git a/test/unit/event.js b/test/unit/event.js index 93049003a..3af8a3fde 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1155,6 +1155,25 @@ test(".trigger() bubbling on disconnected elements (#10489)", function() { jQuery( window ).off( "click" ); }); +test(".trigger() doesn't bubble load event (#10717)", function() { + expect(1); + + jQuery( window ).on( "load", function(){ + ok( false, "load fired on window" ); + }); + + // It's not an image, but as long as it fires load... + jQuery( '' ) + .appendTo( "body" ) + .on( "load", function() { + ok( true, "load fired on img" ); + }) + .trigger( "load" ) + .remove(); + + jQuery( window ).off( "load" ); +}); + test("jQuery.Event( type, props )", function() { expect(5);