Skip to content

Commit

Permalink
remove null to 0 transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
bl00mber committed Apr 2, 2020
1 parent ee40b3f commit c4e3619
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 c4e3619

Please sign in to comment.