Skip to content

Commit

Permalink
Noop unstable_batchedUpdates (#28120)
Browse files Browse the repository at this point in the history
## Overview

`unstable_batchedUpdates` is effectively a no-op outside of legacy mode,
this PR makes it an actual no-op outside legacy mode.

DiffTrain build for [63651c4](63651c4)
  • Loading branch information
rickhanlonii committed Mar 28, 2024
1 parent 9d23ab1 commit 69b2f2d
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 255 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
78328c0c4d70c9b9ee4ad2d6a2319c95e628dd2d
63651c49e068a04cdc6ee1e2fa9c6125167987d2
39 changes: 24 additions & 15 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32491,21 +32491,23 @@ if (__DEV__) {
return executionContext;
}
function batchedUpdates$1(fn, a) {
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;
{
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;

try {
return fn(a);
} finally {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
try {
return fn(a);
} finally {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.

if (
executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
!ReactCurrentActQueue.isBatchingLegacy
) {
resetRenderTimer();
flushSyncWorkOnLegacyRootsOnly();
if (
executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
!ReactCurrentActQueue.isBatchingLegacy
) {
resetRenderTimer();
flushSyncWorkOnLegacyRootsOnly();
}
}
}
}
Expand Down Expand Up @@ -36349,7 +36351,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-1e457a42";
var ReactVersion = "19.0.0-www-classic-31c745b2";

function createPortal$1(
children,
Expand Down Expand Up @@ -49617,6 +49619,13 @@ if (__DEV__) {
} // Expose findDOMNode on internals

Internals.findDOMNode = findDOMNode;

function unstable_batchedUpdates(fn, a) {
// batchedUpdates was a legacy mode feature that is a no-op outside of
// legacy mode. In 19, we made it an actual no-op, but we're keeping it
// for now since there may be libraries that still include it.
return fn(a);
}
// This is an array for better minification.

Internals.Events = [
Expand All @@ -49625,7 +49634,7 @@ if (__DEV__) {
getFiberCurrentPropsFromNode,
enqueueStateRestore,
restoreStateIfNeeded,
batchedUpdates$1
unstable_batchedUpdates
];
var foundDevTools = injectIntoDevTools({
findFiberByHostInstance: getClosestInstanceFromNode,
Expand Down
41 changes: 25 additions & 16 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -32348,21 +32348,23 @@ if (__DEV__) {
return executionContext;
}
function batchedUpdates$1(fn, a) {
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;
{
var prevExecutionContext = executionContext;
executionContext |= BatchedContext;

try {
return fn(a);
} finally {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
try {
return fn(a);
} finally {
executionContext = prevExecutionContext; // If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.

if (
executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
!ReactCurrentActQueue.isBatchingLegacy
) {
resetRenderTimer();
flushSyncWorkOnLegacyRootsOnly();
if (
executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode.
!ReactCurrentActQueue.isBatchingLegacy
) {
resetRenderTimer();
flushSyncWorkOnLegacyRootsOnly();
}
}
}
}
Expand Down Expand Up @@ -36197,7 +36199,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-modern-44db9222";
var ReactVersion = "19.0.0-www-modern-c752b0b8";

function createPortal$1(
children,
Expand Down Expand Up @@ -48843,6 +48845,13 @@ if (__DEV__) {
} // Expose findDOMNode on internals

Internals.findDOMNode = findDOMNode;

function unstable_batchedUpdates(fn, a) {
// batchedUpdates was a legacy mode feature that is a no-op outside of
// legacy mode. In 19, we made it an actual no-op, but we're keeping it
// for now since there may be libraries that still include it.
return fn(a);
}
// This is an array for better minification.

Internals.Events = [
Expand All @@ -48851,7 +48860,7 @@ if (__DEV__) {
getFiberCurrentPropsFromNode,
enqueueStateRestore,
restoreStateIfNeeded,
batchedUpdates$1
unstable_batchedUpdates
];
var foundDevTools = injectIntoDevTools({
findFiberByHostInstance: getClosestInstanceFromNode,
Expand Down Expand Up @@ -48967,7 +48976,7 @@ if (__DEV__) {
exports.preinitModule = preinitModule;
exports.preload = preload;
exports.preloadModule = preloadModule;
exports.unstable_batchedUpdates = batchedUpdates$1;
exports.unstable_batchedUpdates = unstable_batchedUpdates;
exports.unstable_createEventHandle = createEventHandle;
exports.unstable_runWithPriority = runWithPriority;
exports.useFormState = useFormState;
Expand Down
10 changes: 6 additions & 4 deletions compiled/facebook-www/ReactDOM-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -17104,12 +17104,14 @@ Internals.Events = [
getFiberCurrentPropsFromNode,
enqueueStateRestore,
restoreStateIfNeeded,
batchedUpdates$1
function (fn, a) {
return fn(a);
}
];
var devToolsConfig$jscomp$inline_1732 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-classic-49cd2ee2",
version: "19.0.0-www-classic-9df81848",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2160 = {
Expand Down Expand Up @@ -17139,7 +17141,7 @@ var internals$jscomp$inline_2160 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-classic-49cd2ee2"
reconcilerVersion: "19.0.0-www-classic-9df81848"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2161 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -17589,4 +17591,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-classic-49cd2ee2";
exports.version = "19.0.0-www-classic-9df81848";
111 changes: 58 additions & 53 deletions compiled/facebook-www/ReactDOM-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -10978,18 +10978,6 @@ function performSyncWorkOnRoot(root, lanes) {
ensureRootIsScheduled(root);
return null;
}
function batchedUpdates$1(fn, a) {
var prevExecutionContext = executionContext;
executionContext |= 1;
try {
return fn(a);
} finally {
(executionContext = prevExecutionContext),
0 === executionContext &&
((workInProgressRootRenderTargetTime = now() + 500),
flushSyncWorkAcrossRoots_impl(!0));
}
}
function flushSync$1(fn) {
null !== rootWithPendingPassiveEffects &&
0 === rootWithPendingPassiveEffects.tag &&
Expand Down Expand Up @@ -12257,7 +12245,21 @@ function batchedUpdates(fn, a, b) {
if (isInsideEventHandler) return fn(a, b);
isInsideEventHandler = !0;
try {
return batchedUpdates$1(fn, a, b);
a: {
b = executionContext;
executionContext |= 1;
try {
var JSCompiler_inline_result = fn(a);
break a;
} finally {
(executionContext = b),
0 === executionContext &&
((workInProgressRootRenderTargetTime = now() + 500),
flushSyncWorkAcrossRoots_impl(!0));
}
JSCompiler_inline_result = void 0;
}
return JSCompiler_inline_result;
} finally {
if (
((isInsideEventHandler = !1),
Expand Down Expand Up @@ -13429,19 +13431,19 @@ function getTargetInstForChangeEvent(domEventName, targetInst) {
}
var isInputEventSupported = !1;
if (canUseDOM) {
var JSCompiler_inline_result$jscomp$341;
var JSCompiler_inline_result$jscomp$342;
if (canUseDOM) {
var isSupported$jscomp$inline_1490 = "oninput" in document;
if (!isSupported$jscomp$inline_1490) {
var element$jscomp$inline_1491 = document.createElement("div");
element$jscomp$inline_1491.setAttribute("oninput", "return;");
isSupported$jscomp$inline_1490 =
"function" === typeof element$jscomp$inline_1491.oninput;
var isSupported$jscomp$inline_1494 = "oninput" in document;
if (!isSupported$jscomp$inline_1494) {
var element$jscomp$inline_1495 = document.createElement("div");
element$jscomp$inline_1495.setAttribute("oninput", "return;");
isSupported$jscomp$inline_1494 =
"function" === typeof element$jscomp$inline_1495.oninput;
}
JSCompiler_inline_result$jscomp$341 = isSupported$jscomp$inline_1490;
} else JSCompiler_inline_result$jscomp$341 = !1;
JSCompiler_inline_result$jscomp$342 = isSupported$jscomp$inline_1494;
} else JSCompiler_inline_result$jscomp$342 = !1;
isInputEventSupported =
JSCompiler_inline_result$jscomp$341 &&
JSCompiler_inline_result$jscomp$342 &&
(!document.documentMode || 9 < document.documentMode);
}
function stopWatchingForValueChange() {
Expand Down Expand Up @@ -13750,20 +13752,20 @@ function registerSimpleEvent(domEventName, reactName) {
registerTwoPhaseEvent(reactName, [domEventName]);
}
for (
var i$jscomp$inline_1531 = 0;
i$jscomp$inline_1531 < simpleEventPluginEvents.length;
i$jscomp$inline_1531++
var i$jscomp$inline_1535 = 0;
i$jscomp$inline_1535 < simpleEventPluginEvents.length;
i$jscomp$inline_1535++
) {
var eventName$jscomp$inline_1532 =
simpleEventPluginEvents[i$jscomp$inline_1531],
domEventName$jscomp$inline_1533 =
eventName$jscomp$inline_1532.toLowerCase(),
capitalizedEvent$jscomp$inline_1534 =
eventName$jscomp$inline_1532[0].toUpperCase() +
eventName$jscomp$inline_1532.slice(1);
var eventName$jscomp$inline_1536 =
simpleEventPluginEvents[i$jscomp$inline_1535],
domEventName$jscomp$inline_1537 =
eventName$jscomp$inline_1536.toLowerCase(),
capitalizedEvent$jscomp$inline_1538 =
eventName$jscomp$inline_1536[0].toUpperCase() +
eventName$jscomp$inline_1536.slice(1);
registerSimpleEvent(
domEventName$jscomp$inline_1533,
"on" + capitalizedEvent$jscomp$inline_1534
domEventName$jscomp$inline_1537,
"on" + capitalizedEvent$jscomp$inline_1538
);
}
registerSimpleEvent(ANIMATION_END, "onAnimationEnd");
Expand Down Expand Up @@ -16609,25 +16611,28 @@ Internals.findDOMNode = function (componentOrElement) {
null === componentOrElement ? null : componentOrElement.stateNode;
return componentOrElement;
};
function unstable_batchedUpdates(fn, a) {
return fn(a);
}
Internals.Events = [
getInstanceFromNode$1,
getNodeFromInstance,
getFiberCurrentPropsFromNode,
enqueueStateRestore,
restoreStateIfNeeded,
batchedUpdates$1
unstable_batchedUpdates
];
var devToolsConfig$jscomp$inline_1689 = {
var devToolsConfig$jscomp$inline_1693 = {
findFiberByHostInstance: getClosestInstanceFromNode,
bundleType: 0,
version: "19.0.0-www-modern-8192012c",
version: "19.0.0-www-modern-8e569007",
rendererPackageName: "react-dom"
};
var internals$jscomp$inline_2116 = {
bundleType: devToolsConfig$jscomp$inline_1689.bundleType,
version: devToolsConfig$jscomp$inline_1689.version,
rendererPackageName: devToolsConfig$jscomp$inline_1689.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1689.rendererConfig,
var internals$jscomp$inline_2122 = {
bundleType: devToolsConfig$jscomp$inline_1693.bundleType,
version: devToolsConfig$jscomp$inline_1693.version,
rendererPackageName: devToolsConfig$jscomp$inline_1693.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1693.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
Expand All @@ -16643,26 +16648,26 @@ var internals$jscomp$inline_2116 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_1689.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_1693.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-www-modern-8192012c"
reconcilerVersion: "19.0.0-www-modern-8e569007"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2117 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_2123 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_2117.isDisabled &&
hook$jscomp$inline_2117.supportsFiber
!hook$jscomp$inline_2123.isDisabled &&
hook$jscomp$inline_2123.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_2117.inject(
internals$jscomp$inline_2116
(rendererID = hook$jscomp$inline_2123.inject(
internals$jscomp$inline_2122
)),
(injectedHook = hook$jscomp$inline_2117);
(injectedHook = hook$jscomp$inline_2123);
} catch (err) {}
}
var ReactFiberErrorDialogWWW = require("ReactFiberErrorDialog");
Expand Down Expand Up @@ -16912,7 +16917,7 @@ exports.preloadModule = function (href, options) {
});
} else ReactDOMCurrentDispatcher.current.preloadModule(href);
};
exports.unstable_batchedUpdates = batchedUpdates$1;
exports.unstable_batchedUpdates = unstable_batchedUpdates;
exports.unstable_createEventHandle = function (type, options) {
function eventHandle(target, callback) {
if ("function" !== typeof callback)
Expand Down Expand Up @@ -16953,4 +16958,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactCurrentDispatcher$2.current.useHostTransitionStatus();
};
exports.version = "19.0.0-www-modern-8192012c";
exports.version = "19.0.0-www-modern-8e569007";
Loading

0 comments on commit 69b2f2d

Please sign in to comment.