From c4e3619145de04f96eed745de1c6c3114b339985 Mon Sep 17 00:00:00 2001 From: Nick Reiley Date: Thu, 2 Apr 2020 15:48:49 +0500 Subject: [PATCH] remove null to 0 transformation --- packages/react-dom/src/events/SyntheticKeyboardEvent.js | 7 +------ .../src/events/__tests__/SyntheticKeyboardEvent-test.js | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/react-dom/src/events/SyntheticKeyboardEvent.js b/packages/react-dom/src/events/SyntheticKeyboardEvent.js index 2db2dd179303b..f083d1b861c4c 100644 --- a/packages/react-dom/src/events/SyntheticKeyboardEvent.js +++ b/packages/react-dom/src/events/SyntheticKeyboardEvent.js @@ -16,12 +16,7 @@ import getEventModifierState from './getEventModifierState'; */ const SyntheticKeyboardEvent = SyntheticUIEvent.extend({ key: getEventKey, - code: function(event) { - if (event.type === 'keydown' || event.type === 'keyup') { - return event.code; - } - return 0; - }, + code: null, location: null, ctrlKey: null, shiftKey: null, diff --git a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js index 9426e58baeb9d..2b56d6b3f3c81 100644 --- a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js +++ b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js @@ -453,7 +453,7 @@ describe('SyntheticKeyboardEvent', () => { }); describe('code', () => { - it('returns code on `keydown`, `keyup` and 0 on `keypress`', () => { + it('returns code on `keydown`, `keyup` and null on `keypress`', () => { let codeDown = null; let codeUp = null; let codePress = null; @@ -487,14 +487,14 @@ describe('SyntheticKeyboardEvent', () => { ); node.dispatchEvent( new KeyboardEvent('keypress', { - charCode: 81, + code: 'KeyQ', bubbles: true, cancelable: true, }), ); expect(codeDown).toBe('KeyQ'); expect(codeUp).toBe('KeyQ'); - expect(codePress).toBe(0); + expect(codePress).toBe(null); }); }); });