@@ -36,11 +36,17 @@ export const topLevelEventsToDispatchConfig: Map<
3636
3737const eventPriorities = new Map ( ) ;
3838
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.
4147
4248// prettier-ignore
43- const discreteEvents = [
49+ const discreteEventPairsForSimpleEventPlugin = [
4450 DOMTopLevelEventTypes . TOP_BLUR , 'blur' ,
4551 DOMTopLevelEventTypes . TOP_CANCEL , 'cancel' ,
4652 DOMTopLevelEventTypes . TOP_CLICK , 'click' ,
@@ -77,8 +83,17 @@ const discreteEvents = [
7783 DOMTopLevelEventTypes . TOP_VOLUME_CHANGE , 'volumeChange' ,
7884] ;
7985
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+
8095// prettier-ignore
81- const userBlockingEvents = [
96+ const userBlockingPairsForSimpleEventPlugin = [
8297 DOMTopLevelEventTypes . TOP_DRAG , 'drag' ,
8398 DOMTopLevelEventTypes . TOP_DRAG_ENTER , 'dragEnter' ,
8499 DOMTopLevelEventTypes . TOP_DRAG_EXIT , 'dragExit' ,
@@ -97,7 +112,7 @@ const userBlockingEvents = [
97112] ;
98113
99114// prettier-ignore
100- const continuousEvents = [
115+ const continuousPairsForSimpleEventPlugin = [
101116 DOMTopLevelEventTypes . TOP_ABORT , 'abort' ,
102117 DOMTopLevelEventTypes . TOP_ANIMATION_END , 'animationEnd' ,
103118 DOMTopLevelEventTypes . TOP_ANIMATION_ITERATION , 'animationIteration' ,
@@ -144,7 +159,7 @@ const continuousEvents = [
144159 * ]);
145160 */
146161
147- function processTopEventTypesByPriority (
162+ function processSimpleEventPluginPairsByPriority (
148163 eventTypes : Array < DOMTopLevelEventType | string > ,
149164 priority : EventPriority ,
150165) : void {
@@ -174,9 +189,30 @@ function processTopEventTypesByPriority(
174189 }
175190}
176191
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 ) ;
180216
181217export function getEventPriorityForPluginSystem (
182218 topLevelType : TopLevelType ,
0 commit comments