66 * @flow
77 */
88
9- import { rethrowCaughtError } from 'shared/ReactErrorUtils' ;
109import invariant from 'shared/invariant' ;
1110
1211import {
1312 injectEventPluginOrder ,
1413 injectEventPluginsByName ,
1514 plugins ,
1615} from './EventPluginRegistry' ;
17- import {
18- executeDispatchesInOrder ,
19- getFiberCurrentPropsFromNode ,
20- } from './EventPluginUtils' ;
16+ import { getFiberCurrentPropsFromNode } from './EventPluginUtils' ;
2117import accumulateInto from './accumulateInto' ;
22- import forEachAccumulated from './forEachAccumulated ' ;
18+ import { runEventsInBatch } from './EventBatching ' ;
2319
2420import type { PluginModule } from './PluginModuleType' ;
2521import type { ReactSyntheticEvent } from './ReactSyntheticEventType' ;
2622import type { Fiber } from 'react-reconciler/src/ReactFiber' ;
2723import type { AnyNativeEvent } from './PluginModuleType' ;
2824import type { TopLevelType } from './TopLevelEventTypes' ;
2925
30- /**
31- * Internal queue of events that have accumulated their dispatches and are
32- * waiting to have their dispatches executed.
33- */
34- let eventQueue : ?( Array < ReactSyntheticEvent > | ReactSyntheticEvent ) = null ;
35-
36- /**
37- * Dispatches an event and releases it back into the pool, unless persistent.
38- *
39- * @param {?object } event Synthetic event to be dispatched.
40- * @private
41- */
42- const executeDispatchesAndRelease = function ( event : ReactSyntheticEvent ) {
43- if ( event ) {
44- executeDispatchesInOrder ( event ) ;
45-
46- if ( ! event . isPersistent ( ) ) {
47- event . constructor . release ( event ) ;
48- }
49- }
50- } ;
51- const executeDispatchesAndReleaseTopLevel = function ( e ) {
52- return executeDispatchesAndRelease ( e ) ;
53- } ;
54-
5526function isInteractive ( tag ) {
5627 return (
5728 tag === 'button' ||
@@ -158,7 +129,7 @@ export function getListener(inst: Fiber, registrationName: string) {
158129 * @return {* } An accumulation of synthetic events.
159130 * @internal
160131 */
161- function extractEvents (
132+ function extractPluginEvents (
162133 topLevelType : TopLevelType ,
163134 targetInst : null | Fiber ,
164135 nativeEvent : AnyNativeEvent ,
@@ -183,39 +154,13 @@ function extractEvents(
183154 return events ;
184155}
185156
186- export function runEventsInBatch (
187- events : Array < ReactSyntheticEvent > | ReactSyntheticEvent | null ,
188- ) {
189- if ( events !== null ) {
190- eventQueue = accumulateInto ( eventQueue , events ) ;
191- }
192-
193- // Set `eventQueue` to null before processing it so that we can tell if more
194- // events get enqueued while processing.
195- const processingEventQueue = eventQueue ;
196- eventQueue = null ;
197-
198- if ( ! processingEventQueue ) {
199- return ;
200- }
201-
202- forEachAccumulated ( processingEventQueue , executeDispatchesAndReleaseTopLevel ) ;
203- invariant (
204- ! eventQueue ,
205- 'processEventQueue(): Additional events were enqueued while processing ' +
206- 'an event queue. Support for this has not yet been implemented.' ,
207- ) ;
208- // This would be a good time to rethrow if any of the event handlers threw.
209- rethrowCaughtError ( ) ;
210- }
211-
212- export function runExtractedEventsInBatch (
157+ export function runExtractedPluginEventsInBatch (
213158 topLevelType : TopLevelType ,
214159 targetInst : null | Fiber ,
215160 nativeEvent : AnyNativeEvent ,
216161 nativeEventTarget : EventTarget ,
217162) {
218- const events = extractEvents (
163+ const events = extractPluginEvents (
219164 topLevelType ,
220165 targetInst ,
221166 nativeEvent ,
0 commit comments