Skip to content
Permalink
Browse files

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.
  • Loading branch information...
dmethvin committed Nov 9, 2011
1 parent 2a9f068 commit 45101de6962186a21bc557d1c55ec4844dfb241e
Showing with 24 additions and 0 deletions.
  1. +5 −0 src/event.js
  2. +19 −0 test/unit/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
@@ -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( '<img src="index.html" />' )
.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);

0 comments on commit 45101de

Please sign in to comment.
You can’t perform that action at this time.