@@ -36,11 +36,17 @@ export const topLevelEventsToDispatchConfig: Map<
36
36
37
37
const eventPriorities = new Map ( ) ;
38
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.
39
+ // We store most of the events in this module in pairs of two strings so we can re-use
40
+ // the code required to apply the same logic for event prioritization and that of the
41
+ // SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code
42
+ // duplication (for which there would be quite a bit). For the events that are not needed
43
+ // for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an
44
+ // array of top level events.
45
+
46
+ // Lastly, we ignore prettier so we can keep the formatting sane.
41
47
42
48
// prettier-ignore
43
- const discreteEvents = [
49
+ const discreteEventPairsForSimpleEventPlugin = [
44
50
DOMTopLevelEventTypes . TOP_BLUR , 'blur' ,
45
51
DOMTopLevelEventTypes . TOP_CANCEL , 'cancel' ,
46
52
DOMTopLevelEventTypes . TOP_CLICK , 'click' ,
@@ -77,8 +83,17 @@ const discreteEvents = [
77
83
DOMTopLevelEventTypes . TOP_VOLUME_CHANGE , 'volumeChange' ,
78
84
] ;
79
85
86
+ const otherDiscreteEvents = [
87
+ DOMTopLevelEventTypes . TOP_CHANGE ,
88
+ DOMTopLevelEventTypes . TOP_SELECTION_CHANGE ,
89
+ DOMTopLevelEventTypes . TOP_TEXT_INPUT ,
90
+ DOMTopLevelEventTypes . TOP_COMPOSITION_START ,
91
+ DOMTopLevelEventTypes . TOP_COMPOSITION_END ,
92
+ DOMTopLevelEventTypes . TOP_COMPOSITION_UPDATE ,
93
+ ] ;
94
+
80
95
// prettier-ignore
81
- const userBlockingEvents = [
96
+ const userBlockingPairsForSimpleEventPlugin = [
82
97
DOMTopLevelEventTypes . TOP_DRAG , 'drag' ,
83
98
DOMTopLevelEventTypes . TOP_DRAG_ENTER , 'dragEnter' ,
84
99
DOMTopLevelEventTypes . TOP_DRAG_EXIT , 'dragExit' ,
@@ -97,7 +112,7 @@ const userBlockingEvents = [
97
112
] ;
98
113
99
114
// prettier-ignore
100
- const continuousEvents = [
115
+ const continuousPairsForSimpleEventPlugin = [
101
116
DOMTopLevelEventTypes . TOP_ABORT , 'abort' ,
102
117
DOMTopLevelEventTypes . TOP_ANIMATION_END , 'animationEnd' ,
103
118
DOMTopLevelEventTypes . TOP_ANIMATION_ITERATION , 'animationIteration' ,
@@ -144,7 +159,7 @@ const continuousEvents = [
144
159
* ]);
145
160
*/
146
161
147
- function processTopEventTypesByPriority (
162
+ function processSimpleEventPluginPairsByPriority (
148
163
eventTypes : Array < DOMTopLevelEventType | string > ,
149
164
priority : EventPriority ,
150
165
) : void {
@@ -174,9 +189,30 @@ function processTopEventTypesByPriority(
174
189
}
175
190
}
176
191
177
- processTopEventTypesByPriority ( discreteEvents , DiscreteEvent ) ;
178
- processTopEventTypesByPriority ( userBlockingEvents , UserBlockingEvent ) ;
179
- processTopEventTypesByPriority ( continuousEvents , ContinuousEvent ) ;
192
+ function processTopEventPairsByPriority (
193
+ eventTypes : Array < DOMTopLevelEventType | string > ,
194
+ priority : EventPriority ,
195
+ ) : void {
196
+ for ( let i = 0 ; i < eventTypes . length ; i ++ ) {
197
+ eventPriorities . set ( eventTypes [ i ] , priority ) ;
198
+ }
199
+ }
200
+
201
+ // SimpleEventPlugin
202
+ processSimpleEventPluginPairsByPriority (
203
+ discreteEventPairsForSimpleEventPlugin ,
204
+ DiscreteEvent ,
205
+ ) ;
206
+ processSimpleEventPluginPairsByPriority (
207
+ userBlockingPairsForSimpleEventPlugin ,
208
+ UserBlockingEvent ,
209
+ ) ;
210
+ processSimpleEventPluginPairsByPriority (
211
+ continuousPairsForSimpleEventPlugin ,
212
+ ContinuousEvent ,
213
+ ) ;
214
+ // Not used by SimpleEventPlugin
215
+ processTopEventPairsByPriority ( otherDiscreteEvents , DiscreteEvent ) ;
180
216
181
217
export function getEventPriorityForPluginSystem (
182
218
topLevelType : TopLevelType ,
0 commit comments