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.
This commit is contained in:
Dave Methvin 2011-11-08 19:32:25 -05:00
parent 2a9f0681de
commit 45101de696
2 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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);