Skip to content

Commit

Permalink
remove 0 to null transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
bl00mber committed Apr 2, 2020
1 parent ee40b3f commit 7b9772a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions packages/react-dom/src/events/SyntheticKeyboardEvent.js
Expand Up @@ -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,
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
});
Expand Down

0 comments on commit 7b9772a

Please sign in to comment.