Skip to content

Commit

Permalink
[Fiber] Disable comments as containers in OSS (#32250)
Browse files Browse the repository at this point in the history
3 years ago we partially disabled comment nodes as valid containers.
Some unflagged support was left in due to legacy APIs like
`unmountComponentAtNode` and `unstable_renderSubtreeIntoContainer` but
these were since removed in React 19. This update flags the remaining
uses of comments as containers.

DiffTrain build for [0605cd9](0605cd9)
  • Loading branch information
gnoff committed Feb 4, 2025
1 parent e401203 commit 2e72f47
Show file tree
Hide file tree
Showing 34 changed files with 482 additions and 712 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8bda71558c8b6f9f19af33271f1bfd0251a1c071
0605cd9f38f8b9d0ca6f8bd9dd3409db8d6c5c81
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8bda71558c8b6f9f19af33271f1bfd0251a1c071
0605cd9f38f8b9d0ca6f8bd9dd3409db8d6c5c81
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-modern-8bda7155-20250204";
exports.version = "19.1.0-www-modern-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-8bda7155-20250204";
exports.version = "19.1.0-www-modern-0605cd9f-20250204";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-8bda7155-20250204";
exports.version = "19.1.0-www-modern-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16932,10 +16932,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-8bda7155-20250204",
version: "19.1.0-www-classic-0605cd9f-20250204",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-8bda7155-20250204"
reconcilerVersion: "19.1.0-www-classic-0605cd9f-20250204"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -16969,7 +16969,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -16704,10 +16704,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-modern-8bda7155-20250204",
version: "19.1.0-www-modern-0605cd9f-20250204",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-8bda7155-20250204"
reconcilerVersion: "19.1.0-www-modern-0605cd9f-20250204"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -16741,7 +16741,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-modern-8bda7155-20250204";
exports.version = "19.1.0-www-modern-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -10813,10 +10813,10 @@ var slice = Array.prototype.slice,
})(React.Component);
var internals$jscomp$inline_1512 = {
bundleType: 0,
version: "19.1.0-www-classic-8bda7155-20250204",
version: "19.1.0-www-classic-0605cd9f-20250204",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-8bda7155-20250204"
reconcilerVersion: "19.1.0-www-classic-0605cd9f-20250204"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1513 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -10842,4 +10842,4 @@ exports.RadialGradient = RadialGradient;
exports.Shape = TYPES.SHAPE;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
6 changes: 3 additions & 3 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -10533,10 +10533,10 @@ var slice = Array.prototype.slice,
})(React.Component);
var internals$jscomp$inline_1485 = {
bundleType: 0,
version: "19.1.0-www-modern-8bda7155-20250204",
version: "19.1.0-www-modern-0605cd9f-20250204",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-modern-8bda7155-20250204"
reconcilerVersion: "19.1.0-www-modern-0605cd9f-20250204"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1486 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand All @@ -10562,4 +10562,4 @@ exports.RadialGradient = RadialGradient;
exports.Shape = TYPES.SHAPE;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-modern-8bda7155-20250204";
exports.version = "19.1.0-www-modern-0605cd9f-20250204";
108 changes: 41 additions & 67 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12828,35 +12828,25 @@ __DEV__ &&
function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
var tag = node.tag;
if (5 === tag || 6 === tag)
if (((node = node.stateNode), before)) {
switch (parent.nodeType) {
case COMMENT_NODE:
parent = parent.parentNode;
break;
case DOCUMENT_NODE:
parent = parent.body;
break;
default:
parent =
"HTML" === parent.nodeName ? parent.ownerDocument.body : parent;
}
parent.insertBefore(node, before);
} else
if (((node = node.stateNode), before))
(parent.nodeType === DOCUMENT_NODE
? parent.body
: parent.nodeType === COMMENT_NODE
? parent.parentNode
: "HTML" === parent.nodeName
? parent.ownerDocument.body
: parent
).insertBefore(node, before);
else
a: {
switch (parent.nodeType) {
case COMMENT_NODE:
before = parent.parentNode;
before.insertBefore(node, parent);
break a;
case DOCUMENT_NODE:
before = parent.body;
break;
default:
before =
"HTML" === parent.nodeName
? parent.ownerDocument.body
: parent;
}
if (parent.nodeType === DOCUMENT_NODE) before = parent.body;
else if (parent.nodeType === COMMENT_NODE) {
before = parent.parentNode;
before.insertBefore(node, parent);
break a;
} else
before =
"HTML" === parent.nodeName ? parent.ownerDocument.body : parent;
before.appendChild(node);
parent = parent._reactRootContainer;
(null !== parent && void 0 !== parent) ||
Expand Down Expand Up @@ -13687,26 +13677,16 @@ __DEV__ &&
null !== hostParent &&
(hostParentIsContainer
? ((nearestMountedAncestor = hostParent),
(deletedFiber = deletedFiber.stateNode),
nearestMountedAncestor.nodeType === COMMENT_NODE
? clearSuspenseBoundary(
nearestMountedAncestor.parentNode,
deletedFiber
)
: nearestMountedAncestor.nodeType === DOCUMENT_NODE
? clearSuspenseBoundary(
nearestMountedAncestor.body,
deletedFiber
)
: "HTML" === nearestMountedAncestor.nodeName
? clearSuspenseBoundary(
nearestMountedAncestor.ownerDocument.body,
deletedFiber
)
: clearSuspenseBoundary(
nearestMountedAncestor,
deletedFiber
),
clearSuspenseBoundary(
nearestMountedAncestor.nodeType === DOCUMENT_NODE
? nearestMountedAncestor.body
: nearestMountedAncestor.nodeType === COMMENT_NODE
? nearestMountedAncestor.parentNode
: "HTML" === nearestMountedAncestor.nodeName
? nearestMountedAncestor.ownerDocument.body
: nearestMountedAncestor,
deletedFiber.stateNode
),
retryIfBlockedOn(nearestMountedAncestor))
: clearSuspenseBoundary(hostParent, deletedFiber.stateNode));
break;
Expand Down Expand Up @@ -21852,20 +21832,14 @@ __DEV__ &&
parentInstance.removeChild(child);
}
function removeChildFromContainer(container, child) {
switch (container.nodeType) {
case COMMENT_NODE:
container = container.parentNode;
break;
case DOCUMENT_NODE:
container = container.body;
break;
default:
container =
"HTML" === container.nodeName
? container.ownerDocument.body
: container;
}
container.removeChild(child);
(container.nodeType === DOCUMENT_NODE
? container.body
: container.nodeType === COMMENT_NODE
? container.parentNode
: "HTML" === container.nodeName
? container.ownerDocument.body
: container
).removeChild(child);
}
function clearSuspenseBoundary(parentInstance, suspenseInstance) {
var node = suspenseInstance,
Expand Down Expand Up @@ -27532,11 +27506,11 @@ __DEV__ &&
return_targetInst = null;
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.1.0-www-classic-8bda7155-20250204" !== isomorphicReactPackageVersion)
if ("19.1.0-www-classic-0605cd9f-20250204" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.1.0-www-classic-8bda7155-20250204\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.1.0-www-classic-0605cd9f-20250204\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -27579,10 +27553,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-8bda7155-20250204",
version: "19.1.0-www-classic-0605cd9f-20250204",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-8bda7155-20250204"
reconcilerVersion: "19.1.0-www-classic-0605cd9f-20250204"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -28180,7 +28154,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.1.0-www-classic-8bda7155-20250204";
exports.version = "19.1.0-www-classic-0605cd9f-20250204";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit 2e72f47

Please sign in to comment.