Skip to content

Commit e94b1e7

Browse files
committed
Fix for but jquery#3861 and it's duplicates (jquery#4197 and jquery#5461).
A browser bug was firing an event when it shouldn't. This fix is so jQuery makes it uniform and cross browser. More info in the bug tracker.
1 parent 155ecf4 commit e94b1e7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/event.js

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

867+
if(event.button && event.type === 'click') return; // fix for #3861
868+
867869
for ( j in live ) {
868870
fn = live[j];
869871
if ( fn.live === event.type ||

test/unit/event.js

Lines changed: 5 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,10 @@ 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"); event.button = 1; jQuery("div#nothiddendiv").trigger(event);
680+
equals( livea, 6, "live secondary click" );
681+
678682
jQuery("div#nothiddendivchild").die("click");
679683
jQuery("div#nothiddendiv").die("click");
680684
jQuery("div").die("click");

0 commit comments

Comments
 (0)