Skip to content

Commit e89d74e

Browse files
committed
Remove decoupleUpdatePriorityFromScheduler
1 parent 5fe091c commit e89d74e

18 files changed

+226
-542
lines changed

packages/react-dom/src/events/ReactDOMEventListener.js

+6-20
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree';
4040

4141
import {
4242
enableLegacyFBSupport,
43-
decoupleUpdatePriorityFromScheduler,
4443
enableNewReconciler,
4544
} from 'shared/ReactFeatureFlags';
4645
import {dispatchEventForPluginEventSystem} from './DOMPluginEventSystem';
@@ -177,25 +176,10 @@ function dispatchContinuousEvent(
177176
container,
178177
nativeEvent,
179178
) {
180-
if (decoupleUpdatePriorityFromScheduler) {
181-
const previousPriority = getCurrentUpdateLanePriority();
182-
try {
183-
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
184-
setCurrentUpdateLanePriority(InputContinuousLanePriority);
185-
runWithPriority(
186-
UserBlockingPriority,
187-
dispatchEvent.bind(
188-
null,
189-
domEventName,
190-
eventSystemFlags,
191-
container,
192-
nativeEvent,
193-
),
194-
);
195-
} finally {
196-
setCurrentUpdateLanePriority(previousPriority);
197-
}
198-
} else {
179+
const previousPriority = getCurrentUpdateLanePriority();
180+
try {
181+
// TODO: Double wrapping is necessary while we decouple Scheduler priority.
182+
setCurrentUpdateLanePriority(InputContinuousLanePriority);
199183
runWithPriority(
200184
UserBlockingPriority,
201185
dispatchEvent.bind(
@@ -206,6 +190,8 @@ function dispatchContinuousEvent(
206190
nativeEvent,
207191
),
208192
);
193+
} finally {
194+
setCurrentUpdateLanePriority(previousPriority);
209195
}
210196
}
211197

packages/react-reconciler/src/ReactFiberHooks.new.js

+28-58
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
enableSchedulingProfiler,
2828
enableNewReconciler,
2929
enableCache,
30-
decoupleUpdatePriorityFromScheduler,
3130
enableUseRefAccessWarning,
3231
enableStrictEffects,
3332
enableLazyContextPropagation,
@@ -1713,66 +1712,37 @@ function rerenderDeferredValue<T>(value: T): T {
17131712

17141713
function startTransition(setPending, callback) {
17151714
const priorityLevel = getCurrentPriorityLevel();
1716-
if (decoupleUpdatePriorityFromScheduler) {
1717-
const previousLanePriority = getCurrentUpdateLanePriority();
1718-
setCurrentUpdateLanePriority(
1719-
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
1720-
);
1715+
const previousLanePriority = getCurrentUpdateLanePriority();
1716+
setCurrentUpdateLanePriority(
1717+
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
1718+
);
17211719

1722-
runWithPriority(
1723-
priorityLevel < UserBlockingPriority
1724-
? UserBlockingPriority
1725-
: priorityLevel,
1726-
() => {
1727-
setPending(true);
1728-
},
1729-
);
1720+
runWithPriority(
1721+
priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
1722+
() => {
1723+
setPending(true);
1724+
},
1725+
);
17301726

1731-
// TODO: Can remove this. Was only necessary because we used to give
1732-
// different behavior to transitions without a config object. Now they are
1733-
// all treated the same.
1734-
setCurrentUpdateLanePriority(DefaultLanePriority);
1727+
// TODO: Can remove this. Was only necessary because we used to give
1728+
// different behavior to transitions without a config object. Now they are
1729+
// all treated the same.
1730+
setCurrentUpdateLanePriority(DefaultLanePriority);
17351731

1736-
runWithPriority(
1737-
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1738-
() => {
1739-
const prevTransition = ReactCurrentBatchConfig.transition;
1740-
ReactCurrentBatchConfig.transition = 1;
1741-
try {
1742-
setPending(false);
1743-
callback();
1744-
} finally {
1745-
if (decoupleUpdatePriorityFromScheduler) {
1746-
setCurrentUpdateLanePriority(previousLanePriority);
1747-
}
1748-
ReactCurrentBatchConfig.transition = prevTransition;
1749-
}
1750-
},
1751-
);
1752-
} else {
1753-
runWithPriority(
1754-
priorityLevel < UserBlockingPriority
1755-
? UserBlockingPriority
1756-
: priorityLevel,
1757-
() => {
1758-
setPending(true);
1759-
},
1760-
);
1761-
1762-
runWithPriority(
1763-
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1764-
() => {
1765-
const prevTransition = ReactCurrentBatchConfig.transition;
1766-
ReactCurrentBatchConfig.transition = 1;
1767-
try {
1768-
setPending(false);
1769-
callback();
1770-
} finally {
1771-
ReactCurrentBatchConfig.transition = prevTransition;
1772-
}
1773-
},
1774-
);
1775-
}
1732+
runWithPriority(
1733+
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1734+
() => {
1735+
const prevTransition = ReactCurrentBatchConfig.transition;
1736+
ReactCurrentBatchConfig.transition = 1;
1737+
try {
1738+
setPending(false);
1739+
callback();
1740+
} finally {
1741+
setCurrentUpdateLanePriority(previousLanePriority);
1742+
ReactCurrentBatchConfig.transition = prevTransition;
1743+
}
1744+
},
1745+
);
17761746
}
17771747

17781748
function mountTransition(): [(() => void) => void, boolean] {

packages/react-reconciler/src/ReactFiberHooks.old.js

+28-58
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
enableSchedulingProfiler,
2828
enableNewReconciler,
2929
enableCache,
30-
decoupleUpdatePriorityFromScheduler,
3130
enableUseRefAccessWarning,
3231
enableStrictEffects,
3332
enableLazyContextPropagation,
@@ -1713,66 +1712,37 @@ function rerenderDeferredValue<T>(value: T): T {
17131712

17141713
function startTransition(setPending, callback) {
17151714
const priorityLevel = getCurrentPriorityLevel();
1716-
if (decoupleUpdatePriorityFromScheduler) {
1717-
const previousLanePriority = getCurrentUpdateLanePriority();
1718-
setCurrentUpdateLanePriority(
1719-
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
1720-
);
1715+
const previousLanePriority = getCurrentUpdateLanePriority();
1716+
setCurrentUpdateLanePriority(
1717+
higherLanePriority(previousLanePriority, InputContinuousLanePriority),
1718+
);
17211719

1722-
runWithPriority(
1723-
priorityLevel < UserBlockingPriority
1724-
? UserBlockingPriority
1725-
: priorityLevel,
1726-
() => {
1727-
setPending(true);
1728-
},
1729-
);
1720+
runWithPriority(
1721+
priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel,
1722+
() => {
1723+
setPending(true);
1724+
},
1725+
);
17301726

1731-
// TODO: Can remove this. Was only necessary because we used to give
1732-
// different behavior to transitions without a config object. Now they are
1733-
// all treated the same.
1734-
setCurrentUpdateLanePriority(DefaultLanePriority);
1727+
// TODO: Can remove this. Was only necessary because we used to give
1728+
// different behavior to transitions without a config object. Now they are
1729+
// all treated the same.
1730+
setCurrentUpdateLanePriority(DefaultLanePriority);
17351731

1736-
runWithPriority(
1737-
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1738-
() => {
1739-
const prevTransition = ReactCurrentBatchConfig.transition;
1740-
ReactCurrentBatchConfig.transition = 1;
1741-
try {
1742-
setPending(false);
1743-
callback();
1744-
} finally {
1745-
if (decoupleUpdatePriorityFromScheduler) {
1746-
setCurrentUpdateLanePriority(previousLanePriority);
1747-
}
1748-
ReactCurrentBatchConfig.transition = prevTransition;
1749-
}
1750-
},
1751-
);
1752-
} else {
1753-
runWithPriority(
1754-
priorityLevel < UserBlockingPriority
1755-
? UserBlockingPriority
1756-
: priorityLevel,
1757-
() => {
1758-
setPending(true);
1759-
},
1760-
);
1761-
1762-
runWithPriority(
1763-
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1764-
() => {
1765-
const prevTransition = ReactCurrentBatchConfig.transition;
1766-
ReactCurrentBatchConfig.transition = 1;
1767-
try {
1768-
setPending(false);
1769-
callback();
1770-
} finally {
1771-
ReactCurrentBatchConfig.transition = prevTransition;
1772-
}
1773-
},
1774-
);
1775-
}
1732+
runWithPriority(
1733+
priorityLevel > NormalPriority ? NormalPriority : priorityLevel,
1734+
() => {
1735+
const prevTransition = ReactCurrentBatchConfig.transition;
1736+
ReactCurrentBatchConfig.transition = 1;
1737+
try {
1738+
setPending(false);
1739+
callback();
1740+
} finally {
1741+
setCurrentUpdateLanePriority(previousLanePriority);
1742+
ReactCurrentBatchConfig.transition = prevTransition;
1743+
}
1744+
},
1745+
);
17761746
}
17771747

17781748
function mountTransition(): [(() => void) => void, boolean] {

0 commit comments

Comments
 (0)