]> source.dussan.org Git - jquery.git/commitdiff
Event: Remove the event.which shim
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Wed, 26 Aug 2020 12:10:33 +0000 (14:10 +0200)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Wed, 26 Aug 2020 12:19:24 +0000 (14:19 +0200)
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 1a5fff4c169dbaa2df72c656868bcf60ed4413d0)

src/event.js

index 99ea0fdb8f73f69df6619cd05d096a7d8eac7521..7d418f11378bdf23ae729db0c66d2a329f9ea95c 100644 (file)
@@ -17,10 +17,7 @@ define( [
 
 "use strict";
 
-var
-       rkeyEvent = /^key/,
-       rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
-       rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
+var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
 
 function returnTrue() {
        return true;
@@ -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 ) {