Skip to content

Commit 150e44c

Browse files
iraejeresig
authored andcommitted
Make sure non-left-click events don't bubble. Fixes #3861.
1 parent 8eef3a4 commit 150e44c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/event.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ function liveHandler( event ) {
864864
related, match, fn, elem, j, i, l, data,
865865
live = jQuery.extend({}, jQuery.data( this, "events" ).live);
866866

867+
// Make sure we avoid non-left-click bubbling in Firefox (#3861)
868+
if ( event.button && event.type === "click" ) {
869+
return;
870+
}
871+
867872
for ( j in live ) {
868873
fn = live[j];
869874
if ( fn.live === event.type ||

test/unit/event.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ test("toggle(Function, Function, ...)", function() {
608608
});
609609

610610
test(".live()/.die()", function() {
611-
expect(61);
611+
expect(62);
612612

613613
var submit = 0, div = 0, livea = 0, liveb = 0;
614614

@@ -675,6 +675,13 @@ test(".live()/.die()", function() {
675675
equals( livea, 6, "stopPropagation Click on inner div" );
676676
equals( liveb, 3, "stopPropagation Click on inner div" );
677677

678+
// Make sure click events only fire with primary click
679+
var event = jQuery.Event("click");
680+
event.button = 1;
681+
jQuery("div#nothiddendiv").trigger(event);
682+
683+
equals( livea, 6, "live secondary click" );
684+
678685
jQuery("div#nothiddendivchild").die("click");
679686
jQuery("div#nothiddendiv").die("click");
680687
jQuery("div").die("click");

0 commit comments

Comments
 (0)