aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-11-08 19:32:25 -0500
committerDave Methvin <dave.methvin@gmail.com>2011-11-08 19:32:25 -0500
commit45101de6962186a21bc557d1c55ec4844dfb241e (patch)
tree742aec024fc8fd78d1bacfc873d4fb4c48f846ab
parent2a9f0681dee3a6421bafd2fbc4451c9fe364b6ca (diff)
downloadjquery-45101de6962186a21bc557d1c55ec4844dfb241e.tar.gz
jquery-45101de6962186a21bc557d1c55ec4844dfb241e.zip
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.
-rw-r--r--src/event.js5
-rw-r--r--test/unit/event.js19
2 files changed, 24 insertions, 0 deletions
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( '<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);