|
9 | 9 | needsStateRestore, |
10 | 10 | restoreStateIfNeeded, |
11 | 11 | } from './ReactDOMControlledComponent'; |
12 | | -import {enableDiscreteEventFlushingChange} from 'shared/ReactFeatureFlags'; |
13 | 12 |
|
14 | 13 | // Used as a way to call batchedUpdates when we don't have a reference to |
15 | 14 | // the renderer. Such as when we're dispatching events or if third party |
@@ -75,6 +74,7 @@ export function batchedEventUpdates(fn, a, b) { |
75 | 74 | } |
76 | 75 | } |
77 | 76 |
|
| 77 | +// TODO: Replace with flushSync |
78 | 78 | export function discreteUpdates(fn, a, b, c, d) { |
79 | 79 | const prevIsInsideEventHandler = isInsideEventHandler; |
80 | 80 | isInsideEventHandler = true; |
@@ -88,32 +88,10 @@ export function discreteUpdates(fn, a, b, c, d) { |
88 | 88 | } |
89 | 89 | } |
90 | 90 |
|
91 | | -let lastFlushedEventTimeStamp = 0; |
| 91 | +// TODO: Replace with flushSync |
92 | 92 | export function flushDiscreteUpdatesIfNeeded(timeStamp: number) { |
93 | | - if (enableDiscreteEventFlushingChange) { |
94 | | - // event.timeStamp isn't overly reliable due to inconsistencies in |
95 | | - // how different browsers have historically provided the time stamp. |
96 | | - // Some browsers provide high-resolution time stamps for all events, |
97 | | - // some provide low-resolution time stamps for all events. FF < 52 |
98 | | - // even mixes both time stamps together. Some browsers even report |
99 | | - // negative time stamps or time stamps that are 0 (iOS9) in some cases. |
100 | | - // Given we are only comparing two time stamps with equality (!==), |
101 | | - // we are safe from the resolution differences. If the time stamp is 0 |
102 | | - // we bail-out of preventing the flush, which can affect semantics, |
103 | | - // such as if an earlier flush removes or adds event listeners that |
104 | | - // are fired in the subsequent flush. However, this is the same |
105 | | - // behaviour as we had before this change, so the risks are low. |
106 | | - if ( |
107 | | - !isInsideEventHandler && |
108 | | - (timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp) |
109 | | - ) { |
110 | | - lastFlushedEventTimeStamp = timeStamp; |
111 | | - flushDiscreteUpdatesImpl(); |
112 | | - } |
113 | | - } else { |
114 | | - if (!isInsideEventHandler) { |
115 | | - flushDiscreteUpdatesImpl(); |
116 | | - } |
| 93 | + if (!isInsideEventHandler) { |
| 94 | + flushDiscreteUpdatesImpl(); |
117 | 95 | } |
118 | 96 | } |
119 | 97 |
|
|