Skip to content

Commit 663835a

Browse files
armujahidnhunzaker
authored andcommitted
Add flow types in getEventModifierState (facebook#13909)
1 parent 8271009 commit 663835a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
68
*/
79

810
/**
911
* Translation from modifier key to the associated property in the event.
1012
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
1113
*/
1214

15+
import type {AnyNativeEvent} from 'events/PluginModuleType';
16+
1317
const modifierKeyToProp = {
1418
Alt: 'altKey',
1519
Control: 'ctrlKey',
@@ -20,7 +24,7 @@ const modifierKeyToProp = {
2024
// IE8 does not implement getModifierState so we simply map it to the only
2125
// modifier keys exposed by the event itself, does not support Lock-keys.
2226
// Currently, all major browsers except Chrome seems to support Lock-keys.
23-
function modifierStateGetter(keyArg) {
27+
function modifierStateGetter(keyArg: string): boolean {
2428
const syntheticEvent = this;
2529
const nativeEvent = syntheticEvent.nativeEvent;
2630
if (nativeEvent.getModifierState) {
@@ -30,7 +34,9 @@ function modifierStateGetter(keyArg) {
3034
return keyProp ? !!nativeEvent[keyProp] : false;
3135
}
3236

33-
function getEventModifierState(nativeEvent) {
37+
function getEventModifierState(
38+
nativeEvent: AnyNativeEvent,
39+
): (keyArg: string) => boolean {
3440
return modifierStateGetter;
3541
}
3642

0 commit comments

Comments
 (0)