@@ -40,21 +40,18 @@ function resetSchedulerState () {
4040// attached during that flush.
4141export let currentFlushTimestamp = 0
4242
43- let getNow
44- if ( inBrowser ) {
45- // Determine what event timestamp the browser is using. Annoyingly, the
46- // timestamp can either be hi-res ( relative to poge load) or low-res
47- // (relative to UNIX epoch), so in order to compare time we have to use the
48- // same timestamp type when saving the flush timestamp.
49- const lowResNow = Date . now ( )
50- const eventTimestamp = document . createEvent ( 'Event' ) . timeStamp
51- // the event timestamp is created after Date.now(), if it's smaller
52- // it means it's using a hi-res timestamp.
53- getNow = eventTimestamp < lowResNow
54- ? ( ) => performance . now ( ) // hi-res
55- : Date . now // low-res
56- } else {
57- getNow = Date . now
43+ // Async edge case fix requires storing an event listener's attach timestamp.
44+ let getNow : ( ) => number = Date . now
45+
46+ // Determine what event timestamp the browser is using. Annoyingly, the
47+ // timestamp can either be hi-res ( relative to poge load) or low-res
48+ // (relative to UNIX epoch), so in order to compare time we have to use the
49+ // same timestamp type when saving the flush timestamp.
50+ if ( inBrowser && getNow ( ) > document . createEvent ( 'Event' ) . timeStamp ) {
51+ // if the low-res timestamp which is bigger than the event timestamp
52+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
53+ // and we need to use the hi-res version for event listeners as well.
54+ getNow = ( ) => performance . now ( )
5855}
5956
6057/**
0 commit comments