[react-dom] Refactor event priority handling to its own module (#17678)
Dominic Gannaway committed
Dec 20, 2019 at 23:15 UTC
85d9655d6f72fc34b71b6b25b1f76a307db81c96
3 files changed
+202
-183
packages/react-dom/src/events/DOMEventProperties.js
new
+189
@@ -0,0 +1,189 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+import type {EventPriority} from 'shared/ReactTypes';
11
+import type {
12
+ TopLevelType,
13
+ DOMTopLevelEventType,
14
+} from 'legacy-events/TopLevelEventTypes';
15
+import type {DispatchConfig} from 'legacy-events/ReactSyntheticEventType';
16
+
17
+import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes';
18
+import {
19
+ DiscreteEvent,
20
+ UserBlockingEvent,
21
+ ContinuousEvent,
22
+} from 'shared/ReactTypes';
23
+
24
+// Needed for SimpleEventPlugin, rather than
25
+// do it in two places, which duplicates logic
26
+// and increases the bundle size, we do it all
27
+// here once. If we remove or refactor the
28
+// SimpleEventPlugin, we should also remove or
29
+// update the below line.
30
+export const simpleEventPluginEventTypes = {};
31
+
32
+export const topLevelEventsToDispatchConfig: Map<
33
+ TopLevelType,
34
+ DispatchConfig,
35
+> = new Map();
36
+
37
+const eventPriorities = new Map();
38
+
39
+// We store all the DOMTopLevelEventTypes and their React Types in pairs of two.
40
+// Furthermore, we ignore prettier so we can keep the formatting sane.
41
+
42
+// prettier-ignore
43
+const discreteEvents = [
44
+ DOMTopLevelEventTypes.TOP_BLUR, 'blur',
45
+ DOMTopLevelEventTypes.TOP_CANCEL, 'cancel',
46
+ DOMTopLevelEventTypes.TOP_CLICK, 'click',
47
+ DOMTopLevelEventTypes.TOP_CLOSE, 'close',
48
+ DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu',
49
+ DOMTopLevelEventTypes.TOP_COPY, 'copy',
50
+ DOMTopLevelEventTypes.TOP_CUT, 'cut',
51
+ DOMTopLevelEventTypes.TOP_AUX_CLICK, 'auxClick',
52
+ DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick',
53
+ DOMTopLevelEventTypes.TOP_DRAG_END, 'dragEnd',
54
+ DOMTopLevelEventTypes.TOP_DRAG_START, 'dragStart',
55
+ DOMTopLevelEventTypes.TOP_DROP, 'drop',
56
+ DOMTopLevelEventTypes.TOP_FOCUS, 'focus',
57
+ DOMTopLevelEventTypes.TOP_INPUT, 'input',
58
+ DOMTopLevelEventTypes.TOP_INVALID, 'invalid',
59
+ DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keyDown',
60
+ DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keyPress',
61
+ DOMTopLevelEventTypes.TOP_KEY_UP, 'keyUp',
62
+ DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown',
63
+ DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp',
64
+ DOMTopLevelEventTypes.TOP_PASTE, 'paste',
65
+ DOMTopLevelEventTypes.TOP_PAUSE, 'pause',
66
+ DOMTopLevelEventTypes.TOP_PLAY, 'play',
67
+ DOMTopLevelEventTypes.TOP_POINTER_CANCEL, 'pointerCancel',
68
+ DOMTopLevelEventTypes.TOP_POINTER_DOWN, 'pointerDown',
69
+ DOMTopLevelEventTypes.TOP_POINTER_UP, 'pointerUp',
70
+ DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange',
71
+ DOMTopLevelEventTypes.TOP_RESET, 'reset',
72
+ DOMTopLevelEventTypes.TOP_SEEKED, 'seeked',
73
+ DOMTopLevelEventTypes.TOP_SUBMIT, 'submit',
74
+ DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel',
75
+ DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd',
76
+ DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart',
77
+ DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange',
78
+];
79
+
80
+// prettier-ignore
81
+const userBlockingEvents = [
82
+ DOMTopLevelEventTypes.TOP_DRAG, 'drag',
83
+ DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter',
84
+ DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit',
85
+ DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave',
86
+ DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragOver',
87
+ DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove',
88
+ DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut',
89
+ DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver',
90
+ DOMTopLevelEventTypes.TOP_POINTER_MOVE, 'pointerMove',
91
+ DOMTopLevelEventTypes.TOP_POINTER_OUT, 'pointerOut',
92
+ DOMTopLevelEventTypes.TOP_POINTER_OVER, 'pointerOver',
93
+ DOMTopLevelEventTypes.TOP_SCROLL, 'scroll',
94
+ DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle',
95
+ DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove',
96
+ DOMTopLevelEventTypes.TOP_WHEEL, 'wheel',
97
+];
98
+
99
+// prettier-ignore
100
+const continuousEvents = [
101
+ DOMTopLevelEventTypes.TOP_ABORT, 'abort',
102
+ DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd',
103
+ DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration',
104
+ DOMTopLevelEventTypes.TOP_ANIMATION_START, 'animationStart',
105
+ DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay',
106
+ DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough',
107
+ DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange',
108
+ DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied',
109
+ DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted',
110
+ DOMTopLevelEventTypes.TOP_ENDED, 'ended',
111
+ DOMTopLevelEventTypes.TOP_ERROR, 'error',
112
+ DOMTopLevelEventTypes.TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture',
113
+ DOMTopLevelEventTypes.TOP_LOAD, 'load',
114
+ DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData',
115
+ DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata',
116
+ DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart',
117
+ DOMTopLevelEventTypes.TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture',
118
+ DOMTopLevelEventTypes.TOP_PLAYING, 'playing',
119
+ DOMTopLevelEventTypes.TOP_PROGRESS, 'progress',
120
+ DOMTopLevelEventTypes.TOP_SEEKING, 'seeking',
121
+ DOMTopLevelEventTypes.TOP_STALLED, 'stalled',
122
+ DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend',
123
+ DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate',
124
+ DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd',
125
+ DOMTopLevelEventTypes.TOP_WAITING, 'waiting',
126
+];
127
+
128
+/**
129
+ * Turns
130
+ * ['abort', ...]
131
+ * into
132
+ * eventTypes = {
133
+ * 'abort': {
134
+ * phasedRegistrationNames: {
135
+ * bubbled: 'onAbort',
136
+ * captured: 'onAbortCapture',
137
+ * },
138
+ * dependencies: [TOP_ABORT],
139
+ * },
140
+ * ...
141
+ * };
142
+ * topLevelEventsToDispatchConfig = new Map([
143
+ * [TOP_ABORT, { sameConfig }],
144
+ * ]);
145
+ */
146
+
147
+function processTopEventTypesByPriority(
148
+ eventTypes: Array<DOMTopLevelEventType | string>,
149
+ priority: EventPriority,
150
+): void {
151
+ // As the event types are in pairs of two, we need to iterate
152
+ // through in twos. The events are in pairs of two to save code
153
+ // and improve init perf of processing this array, as it will
154
+ // result in far fewer object allocations and property accesses
155
+ // if we only use three arrays to process all the categories of
156
+ // instead of tuples.
157
+ for (let i = 0; i < eventTypes.length; i += 2) {
158
+ const topEvent = ((eventTypes[i]: any): DOMTopLevelEventType);
159
+ const event = ((eventTypes[i + 1]: any): string);
160
+ const capitalizedEvent = event[0].toUpperCase() + event.slice(1);
161
+ const onEvent = 'on' + capitalizedEvent;
162
+
163
+ const config = {
164
+ phasedRegistrationNames: {
165
+ bubbled: onEvent,
166
+ captured: onEvent + 'Capture',
167
+ },
168
+ dependencies: [topEvent],
169
+ eventPriority: priority,
170
+ };
171
+ eventPriorities.set(topEvent, priority);
172
+ topLevelEventsToDispatchConfig.set(topEvent, config);
173
+ simpleEventPluginEventTypes[event] = config;
174
+ }
175
+}
176
+
177
+processTopEventTypesByPriority(discreteEvents, DiscreteEvent);
178
+processTopEventTypesByPriority(userBlockingEvents, UserBlockingEvent);
179
+processTopEventTypesByPriority(continuousEvents, ContinuousEvent);
180
+
181
+export function getEventPriorityForPluginSystem(
182
+ topLevelType: TopLevelType,
183
+): EventPriority {
184
+ const priority = eventPriorities.get(topLevelType);
185
+ // Default to a ContinuousEvent. Note: we might
186
+ // want to warn if we can't detect the priority
187
+ // for the event.
188
+ return priority === undefined ? ContinuousEvent : priority;
189
+}
packages/react-dom/src/events/ReactDOMEventListener.js
+2
-4
@@ -59,7 +59,6 @@ import {
59
} from './EventListener';
60
import getEventTarget from './getEventTarget';
61
import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree';
62
-import SimpleEventPlugin from './SimpleEventPlugin';
62
import {getRawEventName} from './DOMTopLevelEventTypes';
63
import {passiveBrowserEventsSupported} from './checkPassiveEvents';
64
@@ -69,14 +68,13 @@ import {
68
ContinuousEvent,
69
DiscreteEvent,
70
} from 'shared/ReactTypes';
71
+import {getEventPriorityForPluginSystem} from './DOMEventProperties';
72
73
const {
74
unstable_UserBlockingPriority: UserBlockingPriority,
75
unstable_runWithPriority: runWithPriority,
76
} = Scheduler;
77
78
-const {getEventPriority} = SimpleEventPlugin;
79
-
78
const CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
79
const callbackBookkeepingPool = [];
80
@@ -280,7 +278,7 @@ function trapEventForPluginEventSystem(
278
capture: boolean,
279
): void {
280
let listener;
283
- switch (getEventPriority(topLevelType)) {
281
+ switch (getEventPriorityForPluginSystem(topLevelType)) {
282
case DiscreteEvent:
283
listener = dispatchDiscreteEvent.bind(
284
null,
packages/react-dom/src/events/SimpleEventPlugin.js
+11
-179
@@ -7,28 +7,23 @@
7
* @flow
8
*/
9
10
-import type {EventPriority} from 'shared/ReactTypes';
10
import type {
11
TopLevelType,
12
DOMTopLevelEventType,
13
} from 'legacy-events/TopLevelEventTypes';
15
-import type {
16
- DispatchConfig,
17
- ReactSyntheticEvent,
18
-} from 'legacy-events/ReactSyntheticEventType';
14
+import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
15
import type {Fiber} from 'react-reconciler/src/ReactFiber';
20
-import type {EventTypes, PluginModule} from 'legacy-events/PluginModuleType';
16
+import type {PluginModule} from 'legacy-events/PluginModuleType';
17
import type {EventSystemFlags} from 'legacy-events/EventSystemFlags';
18
23
-import {
24
- DiscreteEvent,
25
- UserBlockingEvent,
26
- ContinuousEvent,
27
-} from 'shared/ReactTypes';
19
import {accumulateTwoPhaseDispatches} from 'legacy-events/EventPropagators';
20
import SyntheticEvent from 'legacy-events/SyntheticEvent';
21
22
import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes';
23
+import {
24
+ topLevelEventsToDispatchConfig,
25
+ simpleEventPluginEventTypes,
26
+} from './DOMEventProperties';
27
28
import SyntheticAnimationEvent from './SyntheticAnimationEvent';
29
import SyntheticClipboardEvent from './SyntheticClipboardEvent';
@@ -43,163 +38,6 @@ import SyntheticUIEvent from './SyntheticUIEvent';
38
import SyntheticWheelEvent from './SyntheticWheelEvent';
39
import getEventCharCode from './getEventCharCode';
40
46
-/**
47
- * Turns
48
- * ['abort', ...]
49
- * into
50
- * eventTypes = {
51
- * 'abort': {
52
- * phasedRegistrationNames: {
53
- * bubbled: 'onAbort',
54
- * captured: 'onAbortCapture',
55
- * },
56
- * dependencies: [TOP_ABORT],
57
- * },
58
- * ...
59
- * };
60
- * topLevelEventsToDispatchConfig = new Map([
61
- * [TOP_ABORT, { sameConfig }],
62
- * ]);
63
- */
64
-
65
-type EventTuple = [DOMTopLevelEventType, string, EventPriority];
66
-
67
-const eventTuples: Array<EventTuple> = [
68
- // Discrete events
69
- [DOMTopLevelEventTypes.TOP_BLUR, 'blur', DiscreteEvent],
70
- [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel', DiscreteEvent],
71
- [DOMTopLevelEventTypes.TOP_CLICK, 'click', DiscreteEvent],
72
- [DOMTopLevelEventTypes.TOP_CLOSE, 'close', DiscreteEvent],
73
- [DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu', DiscreteEvent],
74
- [DOMTopLevelEventTypes.TOP_COPY, 'copy', DiscreteEvent],
75
- [DOMTopLevelEventTypes.TOP_CUT, 'cut', DiscreteEvent],
76
- [DOMTopLevelEventTypes.TOP_AUX_CLICK, 'auxClick', DiscreteEvent],
77
- [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick', DiscreteEvent],
78
- [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragEnd', DiscreteEvent],
79
- [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragStart', DiscreteEvent],
80
- [DOMTopLevelEventTypes.TOP_DROP, 'drop', DiscreteEvent],
81
- [DOMTopLevelEventTypes.TOP_FOCUS, 'focus', DiscreteEvent],
82
- [DOMTopLevelEventTypes.TOP_INPUT, 'input', DiscreteEvent],
83
- [DOMTopLevelEventTypes.TOP_INVALID, 'invalid', DiscreteEvent],
84
- [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keyDown', DiscreteEvent],
85
- [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keyPress', DiscreteEvent],
86
- [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyUp', DiscreteEvent],
87
- [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown', DiscreteEvent],
88
- [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp', DiscreteEvent],
89
- [DOMTopLevelEventTypes.TOP_PASTE, 'paste', DiscreteEvent],
90
- [DOMTopLevelEventTypes.TOP_PAUSE, 'pause', DiscreteEvent],
91
- [DOMTopLevelEventTypes.TOP_PLAY, 'play', DiscreteEvent],
92
- [DOMTopLevelEventTypes.TOP_POINTER_CANCEL, 'pointerCancel', DiscreteEvent],
93
- [DOMTopLevelEventTypes.TOP_POINTER_DOWN, 'pointerDown', DiscreteEvent],
94
- [DOMTopLevelEventTypes.TOP_POINTER_UP, 'pointerUp', DiscreteEvent],
95
- [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange', DiscreteEvent],
96
- [DOMTopLevelEventTypes.TOP_RESET, 'reset', DiscreteEvent],
97
- [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked', DiscreteEvent],
98
- [DOMTopLevelEventTypes.TOP_SUBMIT, 'submit', DiscreteEvent],
99
- [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel', DiscreteEvent],
100
- [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd', DiscreteEvent],
101
- [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart', DiscreteEvent],
102
- [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange', DiscreteEvent],
103
-
104
- // User-blocking events
105
- [DOMTopLevelEventTypes.TOP_DRAG, 'drag', UserBlockingEvent],
106
- [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter', UserBlockingEvent],
107
- [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit', UserBlockingEvent],
108
- [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave', UserBlockingEvent],
109
- [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragOver', UserBlockingEvent],
110
- [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove', UserBlockingEvent],
111
- [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut', UserBlockingEvent],
112
- [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver', UserBlockingEvent],
113
- [DOMTopLevelEventTypes.TOP_POINTER_MOVE, 'pointerMove', UserBlockingEvent],
114
- [DOMTopLevelEventTypes.TOP_POINTER_OUT, 'pointerOut', UserBlockingEvent],
115
- [DOMTopLevelEventTypes.TOP_POINTER_OVER, 'pointerOver', UserBlockingEvent],
116
- [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll', UserBlockingEvent],
117
- [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle', UserBlockingEvent],
118
- [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove', UserBlockingEvent],
119
- [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel', UserBlockingEvent],
120
-
121
- // Continuous events
122
- [DOMTopLevelEventTypes.TOP_ABORT, 'abort', ContinuousEvent],
123
- [DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd', ContinuousEvent],
124
- [
125
- DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION,
126
- 'animationIteration',
127
- ContinuousEvent,
128
- ],
129
- [
130
- DOMTopLevelEventTypes.TOP_ANIMATION_START,
131
- 'animationStart',
132
- ContinuousEvent,
133
- ],
134
- [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay', ContinuousEvent],
135
- [
136
- DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH,
137
- 'canPlayThrough',
138
- ContinuousEvent,
139
- ],
140
- [
141
- DOMTopLevelEventTypes.TOP_DURATION_CHANGE,
142
- 'durationChange',
143
- ContinuousEvent,
144
- ],
145
- [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied', ContinuousEvent],
146
- [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted', ContinuousEvent],
147
- [DOMTopLevelEventTypes.TOP_ENDED, 'ended', ContinuousEvent],
148
- [DOMTopLevelEventTypes.TOP_ERROR, 'error', ContinuousEvent],
149
- [
150
- DOMTopLevelEventTypes.TOP_GOT_POINTER_CAPTURE,
151
- 'gotPointerCapture',
152
- ContinuousEvent,
153
- ],
154
- [DOMTopLevelEventTypes.TOP_LOAD, 'load', ContinuousEvent],
155
- [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData', ContinuousEvent],
156
- [
157
- DOMTopLevelEventTypes.TOP_LOADED_METADATA,
158
- 'loadedMetadata',
159
- ContinuousEvent,
160
- ],
161
- [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart', ContinuousEvent],
162
- [
163
- DOMTopLevelEventTypes.TOP_LOST_POINTER_CAPTURE,
164
- 'lostPointerCapture',
165
- ContinuousEvent,
166
- ],
167
- [DOMTopLevelEventTypes.TOP_PLAYING, 'playing', ContinuousEvent],
168
- [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress', ContinuousEvent],
169
- [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking', ContinuousEvent],
170
- [DOMTopLevelEventTypes.TOP_STALLED, 'stalled', ContinuousEvent],
171
- [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend', ContinuousEvent],
172
- [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate', ContinuousEvent],
173
- [DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd', ContinuousEvent],
174
- [DOMTopLevelEventTypes.TOP_WAITING, 'waiting', ContinuousEvent],
175
-];
176
-
177
-const eventTypes: EventTypes = {};
178
-const topLevelEventsToDispatchConfig: {
179
- [key: TopLevelType]: DispatchConfig,
180
-} = {};
181
-
182
-for (let i = 0; i < eventTuples.length; i++) {
183
- const eventTuple = eventTuples[i];
184
- const topEvent = eventTuple[0];
185
- const event = eventTuple[1];
186
- const eventPriority = eventTuple[2];
187
-
188
- const capitalizedEvent = event[0].toUpperCase() + event.slice(1);
189
- const onEvent = 'on' + capitalizedEvent;
190
-
191
- const config = {
192
- phasedRegistrationNames: {
193
- bubbled: onEvent,
194
- captured: onEvent + 'Capture',
195
- },
196
- dependencies: [topEvent],
197
- eventPriority,
198
- };
199
- eventTypes[event] = config;
200
- topLevelEventsToDispatchConfig[topEvent] = config;
201
-}
202
-
41
// Only used in DEV for exhaustiveness validation.
42
const knownHTMLTopLevelTypes: Array<DOMTopLevelEventType> = [
43
DOMTopLevelEventTypes.TOP_ABORT,
@@ -235,16 +73,10 @@ const knownHTMLTopLevelTypes: Array<DOMTopLevelEventType> = [
73
DOMTopLevelEventTypes.TOP_WAITING,
74
];
75
238
-const SimpleEventPlugin: PluginModule<MouseEvent> & {
239
- getEventPriority: (topLevelType: TopLevelType) => EventPriority,
240
-} = {
241
- eventTypes: eventTypes,
242
-
243
- getEventPriority(topLevelType: TopLevelType): EventPriority {
244
- const config = topLevelEventsToDispatchConfig[topLevelType];
245
- return config !== undefined ? config.eventPriority : ContinuousEvent;
246
- },
247
-
76
+const SimpleEventPlugin: PluginModule<MouseEvent> = {
77
+ // simpleEventPluginEventTypes gets populated from
78
+ // the DOMEventProperties module.
79
+ eventTypes: simpleEventPluginEventTypes,
80
extractEvents: function(
81
topLevelType: TopLevelType,
82
targetInst: null | Fiber,
@@ -252,7 +84,7 @@ const SimpleEventPlugin: PluginModule<MouseEvent> & {
84
nativeEventTarget: null | EventTarget,
85
eventSystemFlags: EventSystemFlags,
86
): null | ReactSyntheticEvent {
255
- const dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
87
+ const dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType);
88
if (!dispatchConfig) {
89
return null;
90
}