@@ -56,19 +56,6 @@ export function setListenToResponderEventTypes(
56
56
listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl ;
57
57
}
58
58
59
- type ResponderTimeout = { |
60
- id : TimeoutID ,
61
- timers : Map < number , ResponderTimer> ,
62
- | } ;
63
-
64
- type ResponderTimer = { |
65
- instance : ReactDOMEventResponderInstance ,
66
- func : ( ) => void ,
67
- id : number ,
68
- timeStamp : number ,
69
- | } ;
70
-
71
- const activeTimeouts : Map < number , ResponderTimeout > = new Map ( ) ;
72
59
const rootEventTypesToEventResponderInstances : Map <
73
60
DOMTopLevelEventType | string ,
74
61
Set < ReactDOMEventResponderInstance > ,
@@ -80,9 +67,7 @@ const DoNotPropagateToNextResponder = 0;
80
67
const PropagateToNextResponder = 1 ;
81
68
82
69
let currentTimeStamp = 0 ;
83
- let currentTimers = new Map ( ) ;
84
70
let currentInstance : null | ReactDOMEventResponderInstance = null ;
85
- let currentTimerIDCounter = 0 ;
86
71
let currentDocument : null | Document = null ;
87
72
let currentPropagationBehavior : PropagationBehavior = DoNotPropagateToNextResponder ;
88
73
@@ -202,46 +187,6 @@ const eventResponderContext: ReactDOMResponderContext = {
202
187
}
203
188
}
204
189
} ,
205
- setTimeout ( func : ( ) = > void , delay ) : number {
206
- validateResponderContext ( ) ;
207
- if ( currentTimers === null ) {
208
- currentTimers = new Map ( ) ;
209
- }
210
- let timeout = currentTimers . get ( delay ) ;
211
-
212
- const timerId = currentTimerIDCounter ++ ;
213
- if ( timeout === undefined ) {
214
- const timers = new Map ( ) ;
215
- const id = setTimeout ( ( ) => {
216
- processTimers ( timers , delay ) ;
217
- } , delay ) ;
218
- timeout = {
219
- id,
220
- timers,
221
- } ;
222
- currentTimers . set ( delay , timeout ) ;
223
- }
224
- timeout . timers . set ( timerId , {
225
- instance : ( ( currentInstance : any ) : ReactDOMEventResponderInstance ) ,
226
- func,
227
- id : timerId ,
228
- timeStamp : currentTimeStamp ,
229
- } ) ;
230
- activeTimeouts . set ( timerId , timeout ) ;
231
- return timerId ;
232
- } ,
233
- clearTimeout ( timerId : number ) : void {
234
- validateResponderContext ( ) ;
235
- const timeout = activeTimeouts . get ( timerId ) ;
236
-
237
- if ( timeout !== undefined ) {
238
- const timers = timeout . timers ;
239
- timers . delete ( timerId ) ;
240
- if ( timers . size === 0 ) {
241
- clearTimeout ( timeout . id ) ;
242
- }
243
- }
244
- } ,
245
190
getActiveDocument ,
246
191
objectAssign : Object . assign ,
247
192
getTimeStamp ( ) : number {
@@ -340,33 +285,6 @@ function getActiveDocument(): Document {
340
285
return ( ( currentDocument : any ) : Document ) ;
341
286
}
342
287
343
- function processTimers (
344
- timers : Map < number , ResponderTimer > ,
345
- delay : number ,
346
- ) : void {
347
- const timersArr = Array . from ( timers . values ( ) ) ;
348
- const previousInstance = currentInstance ;
349
- const previousTimers = currentTimers ;
350
- try {
351
- batchedEventUpdates ( ( ) => {
352
- for ( let i = 0 ; i < timersArr . length ; i ++ ) {
353
- const { instance, func, id, timeStamp} = timersArr [ i ] ;
354
- currentInstance = instance ;
355
- currentTimeStamp = timeStamp + delay ;
356
- try {
357
- func ( ) ;
358
- } finally {
359
- activeTimeouts . delete ( id ) ;
360
- }
361
- }
362
- } ) ;
363
- } finally {
364
- currentTimers = previousTimers ;
365
- currentInstance = previousInstance ;
366
- currentTimeStamp = 0 ;
367
- }
368
- }
369
-
370
288
function createDOMResponderEvent (
371
289
topLevelType : string ,
372
290
nativeEvent : AnyNativeEvent ,
@@ -510,15 +428,13 @@ export function mountEventResponder(
510
428
const onMount = responder . onMount ;
511
429
if ( onMount !== null ) {
512
430
const previousInstance = currentInstance ;
513
- const previousTimers = currentTimers ;
514
431
currentInstance = responderInstance ;
515
432
try {
516
433
batchedEventUpdates ( ( ) => {
517
434
onMount ( eventResponderContext , props , state ) ;
518
435
} ) ;
519
436
} finally {
520
437
currentInstance = previousInstance ;
521
- currentTimers = previousTimers ;
522
438
}
523
439
}
524
440
}
@@ -531,15 +447,13 @@ export function unmountEventResponder(
531
447
if ( onUnmount !== null ) {
532
448
let { props , state } = responderInstance ;
533
449
const previousInstance = currentInstance ;
534
- const previousTimers = currentTimers ;
535
450
currentInstance = responderInstance ;
536
451
try {
537
452
batchedEventUpdates ( ( ) => {
538
453
onUnmount ( eventResponderContext , props , state ) ;
539
454
} ) ;
540
455
} finally {
541
456
currentInstance = previousInstance ;
542
- currentTimers = previousTimers ;
543
457
}
544
458
}
545
459
const rootEventTypesSet = responderInstance . rootEventTypes ;
@@ -561,8 +475,7 @@ export function unmountEventResponder(
561
475
function validateResponderContext ( ) : void {
562
476
invariant (
563
477
currentInstance !== null ,
564
- 'An event responder context was used outside of an event cycle. ' +
565
- 'Use context.setTimeout() to use asynchronous responder context outside of event cycle .' ,
478
+ 'An event responder context was used outside of an event cycle.' ,
566
479
) ;
567
480
}
568
481
@@ -575,12 +488,10 @@ export function dispatchEventForResponderEventSystem(
575
488
) : void {
576
489
if ( enableFlareAPI ) {
577
490
const previousInstance = currentInstance ;
578
- const previousTimers = currentTimers ;
579
491
const previousTimeStamp = currentTimeStamp ;
580
492
const previousDocument = currentDocument ;
581
493
const previousPropagationBehavior = currentPropagationBehavior ;
582
494
currentPropagationBehavior = DoNotPropagateToNextResponder ;
583
- currentTimers = null ;
584
495
// nodeType 9 is DOCUMENT_NODE
585
496
currentDocument =
586
497
( nativeEventTarget : any ) . nodeType === 9
@@ -599,7 +510,6 @@ export function dispatchEventForResponderEventSystem(
599
510
) ;
600
511
} ) ;
601
512
} finally {
602
- currentTimers = previousTimers ;
603
513
currentInstance = previousInstance ;
604
514
currentTimeStamp = previousTimeStamp ;
605
515
currentDocument = previousDocument ;
0 commit comments