@@ -271,6 +271,20 @@ export class DOMEvent implements Event {
271
271
this . listenersLive . onMutation = null ;
272
272
}
273
273
274
+ /**
275
+ * Resets any internal state to allow the event to be redispatched. Call
276
+ * this before returning from dispatchTo().
277
+ */
278
+ // Declaring this on the prototype rather than as an arrow function saves
279
+ // 190 nanoseconds per dispatchTo().
280
+ private resetForRedispatch ( ) {
281
+ this . currentTarget = null ;
282
+ this . target = null ;
283
+ this . eventPhase = this . NONE ;
284
+ this . propagationState = EventPropagationState . resume ;
285
+ this . listenersLive = emptyArray ;
286
+ this . listenersLazyCopy = emptyArray ;
287
+ }
274
288
/**
275
289
* Dispatches a synthetic event event to target and returns true if either
276
290
* event's cancelable attribute value is false or its preventDefault()
@@ -288,19 +302,6 @@ export class DOMEvent implements Event {
288
302
// completed the breaking changes to migrate fully to DOMEvents.
289
303
DOMEvent . unstable_currentEvent = this ;
290
304
291
- /**
292
- * Resets any internal state to allow the event to be redispatched. Call
293
- * this before returning.
294
- */
295
- const reset = ( ) => {
296
- this . currentTarget = null ;
297
- this . target = null ;
298
- this . eventPhase = this . NONE ;
299
- this . propagationState = EventPropagationState . resume ;
300
- this . listenersLive = emptyArray ;
301
- this . listenersLazyCopy = emptyArray ;
302
- } ;
303
-
304
305
// `Observable.removeEventListener` would likely suffice, but grabbing
305
306
// the static method named `removeEventListener` on the target's class
306
307
// allows us to be robust to the possiblity of the case of the target
@@ -348,7 +349,7 @@ export class DOMEvent implements Event {
348
349
} ) ;
349
350
350
351
if ( this . propagationState !== EventPropagationState . resume ) {
351
- reset ( ) ;
352
+ this . resetForRedispatch ( ) ;
352
353
return ! this . defaultPrevented ;
353
354
}
354
355
}
@@ -368,15 +369,15 @@ export class DOMEvent implements Event {
368
369
} ) ;
369
370
370
371
if ( this . propagationState !== EventPropagationState . resume ) {
371
- reset ( ) ;
372
+ this . resetForRedispatch ( ) ;
372
373
return ! this . defaultPrevented ;
373
374
}
374
375
375
376
// If the event doesn't bubble, then, having dispatched it at the
376
377
// target (the first iteration of this loop) we don't let it
377
378
// propagate any further.
378
379
if ( ! this . bubbles ) {
379
- reset ( ) ;
380
+ this . resetForRedispatch ( ) ;
380
381
break ;
381
382
}
382
383
@@ -393,7 +394,7 @@ export class DOMEvent implements Event {
393
394
phase : this . BUBBLING_PHASE ,
394
395
} ) ;
395
396
396
- reset ( ) ;
397
+ this . resetForRedispatch ( ) ;
397
398
return ! this . defaultPrevented ;
398
399
}
399
400
0 commit comments