Skip to content

Commit 7b9772a

Browse files
committed
remove 0 to null transformation
1 parent ee40b3f commit 7b9772a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/react-dom/src/events/SyntheticKeyboardEvent.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ import getEventModifierState from './getEventModifierState';
1616
*/
1717
const SyntheticKeyboardEvent = SyntheticUIEvent.extend({
1818
key: getEventKey,
19-
code: function(event) {
20-
if (event.type === 'keydown' || event.type === 'keyup') {
21-
return event.code;
22-
}
23-
return 0;
24-
},
19+
code: null,
2520
location: null,
2621
ctrlKey: null,
2722
shiftKey: null,

packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ describe('SyntheticKeyboardEvent', () => {
453453
});
454454

455455
describe('code', () => {
456-
it('returns code on `keydown`, `keyup` and 0 on `keypress`', () => {
456+
it('returns code on `keydown`, `keyup` and null on `keypress`', () => {
457457
let codeDown = null;
458458
let codeUp = null;
459459
let codePress = null;
@@ -487,14 +487,14 @@ describe('SyntheticKeyboardEvent', () => {
487487
);
488488
node.dispatchEvent(
489489
new KeyboardEvent('keypress', {
490-
charCode: 81,
490+
code: 'KeyQ',
491491
bubbles: true,
492492
cancelable: true,
493493
}),
494494
);
495495
expect(codeDown).toBe('KeyQ');
496496
expect(codeUp).toBe('KeyQ');
497-
expect(codePress).toBe(0);
497+
expect(codePress).toBe(null);
498498
});
499499
});
500500
});

0 commit comments

Comments
 (0)