Skip to content

Commit

Permalink
Event: Remove the event.which shim
Browse files Browse the repository at this point in the history
All supported browsers implement this property by themselves. The shim was only
needed for IE <9.

Fixes gh-3235
Closes gh-4765
Ref gh-4755

(cherry picked from commit 1a5fff4)
  • Loading branch information
mgol committed Aug 26, 2020
1 parent 3bae54a commit 2bf9793
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ define( [

"use strict";

var
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;

function returnTrue() {
return true;
Expand Down Expand Up @@ -749,34 +746,7 @@ jQuery.each( {
targetTouches: true,
toElement: true,
touches: true,

which: function( event ) {
var button = event.button;

// Add which for key events
if ( event.which == null && rkeyEvent.test( event.type ) ) {
return event.charCode != null ? event.charCode : event.keyCode;
}

// Add which for click: 1 === left; 2 === middle; 3 === right
if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
if ( button & 1 ) {
return 1;
}

if ( button & 2 ) {
return 3;
}

if ( button & 4 ) {
return 2;
}

return 0;
}

return event.which;
}
which: true
}, jQuery.event.addProp );

jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
Expand Down

0 comments on commit 2bf9793

Please sign in to comment.