Skip to content

Commit e11bf42

Browse files
authored
Check for Suspense boundary in a root Container (#16673)
If we find a Container that might mean that we're on a node that is inside a Suspense boundary that is directly inside the Container root. Imagine the div is a Container and the span is a dehydrated instance: ``` <div> <!--$--> <span /> <!--/$--> </div> ``` There's no way to tests this yet since I'm not actually utilizing the return value yet. The solution is to just use the same path to check for a Suspense boundary as if we find a parent instance.
1 parent 962dfc2 commit e11bf42

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/react-dom/src/client/ReactDOMComponentTree.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ export function getClosestInstanceFromNode(targetNode) {
4949
// instance. Note that we don't check this field on the targetNode
5050
// itself because the fibers are conceptually between the container
5151
// node and the first child. It isn't surrounding the container node.
52-
targetInst = parentNode[internalContainerInstanceKey];
53-
if (targetInst) {
54-
// If so, we return the HostRoot Fiber.
55-
return targetInst;
56-
}
57-
targetInst = parentNode[internalInstanceKey];
52+
// If it's not a container, we check if it's an instance.
53+
targetInst =
54+
parentNode[internalContainerInstanceKey] ||
55+
parentNode[internalInstanceKey];
5856
if (targetInst) {
5957
// Since this wasn't the direct target of the event, we might have
6058
// stepped past dehydrated DOM nodes to get here. However they could

0 commit comments

Comments
 (0)