@@ -17,6 +17,7 @@ import type {
1717 Container ,
1818 TextInstance ,
1919 Instance ,
20+ ActivityInstance ,
2021 SuspenseInstance ,
2122 Props ,
2223 HoistableRoot ,
@@ -30,9 +31,10 @@ import {
3031 HostText ,
3132 HostRoot ,
3233 SuspenseComponent ,
34+ ActivityComponent ,
3335} from 'react-reconciler/src/ReactWorkTags' ;
3436
35- import { getParentSuspenseInstance } from './ReactFiberConfigDOM' ;
37+ import { getParentHydrationBoundary } from './ReactFiberConfigDOM' ;
3638
3739import { enableScopeAPI } from 'shared/ReactFeatureFlags' ;
3840
@@ -59,7 +61,12 @@ export function detachDeletedInstance(node: Instance): void {
5961
6062export function precacheFiberNode (
6163 hostInst : Fiber ,
62- node : Instance | TextInstance | SuspenseInstance | ReactScopeInstance ,
64+ node :
65+ | Instance
66+ | TextInstance
67+ | SuspenseInstance
68+ | ActivityInstance
69+ | ReactScopeInstance ,
6370) : void {
6471 ( node : any ) [ internalInstanceKey ] = hostInst ;
6572}
@@ -81,15 +88,16 @@ export function isContainerMarkedAsRoot(node: Container): boolean {
8188
8289// Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
8390// If the target node is part of a hydrated or not yet rendered subtree, then
84- // this may also return a SuspenseComponent or HostRoot to indicate that.
91+ // this may also return a SuspenseComponent, ActivityComponent or HostRoot to
92+ // indicate that.
8593// Conceptually the HostRoot fiber is a child of the Container node. So if you
8694// pass the Container node as the targetNode, you will not actually get the
8795// HostRoot back. To get to the HostRoot, you need to pass a child of it.
88- // The same thing applies to Suspense boundaries.
96+ // The same thing applies to Suspense and Activity boundaries.
8997export function getClosestInstanceFromNode ( targetNode : Node ) : null | Fiber {
9098 let targetInst = ( targetNode : any ) [ internalInstanceKey ] ;
9199 if ( targetInst ) {
92- // Don't return HostRoot or SuspenseComponent here.
100+ // Don't return HostRoot, SuspenseComponent or ActivityComponent here.
93101 return targetInst ;
94102 }
95103 // If the direct event target isn't a React owned DOM node, we need to look
@@ -129,8 +137,8 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
129137 ) {
130138 // Next we need to figure out if the node that skipped past is
131139 // nested within a dehydrated boundary and if so, which one.
132- let suspenseInstance = getParentSuspenseInstance ( targetNode ) ;
133- while ( suspenseInstance !== null ) {
140+ let hydrationInstance = getParentHydrationBoundary ( targetNode ) ;
141+ while ( hydrationInstance !== null ) {
134142 // We found a suspense instance. That means that we haven't
135143 // hydrated it yet. Even though we leave the comments in the
136144 // DOM after hydrating, and there are boundaries in the DOM
@@ -140,15 +148,15 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
140148 // Let's get the fiber associated with the SuspenseComponent
141149 // as the deepest instance.
142150 // $FlowFixMe[prop-missing]
143- const targetSuspenseInst = suspenseInstance [ internalInstanceKey ] ;
144- if ( targetSuspenseInst ) {
145- return targetSuspenseInst ;
151+ const targetFiber = hydrationInstance [ internalInstanceKey ] ;
152+ if ( targetFiber ) {
153+ return targetFiber ;
146154 }
147155 // If we don't find a Fiber on the comment, it might be because
148156 // we haven't gotten to hydrate it yet. There might still be a
149157 // parent boundary that hasn't above this one so we need to find
150158 // the outer most that is known.
151- suspenseInstance = getParentSuspenseInstance ( suspenseInstance ) ;
159+ hydrationInstance = getParentHydrationBoundary ( hydrationInstance ) ;
152160 // If we don't find one, then that should mean that the parent
153161 // host component also hasn't hydrated yet. We can return it
154162 // below since it will bail out on the isMounted check later.
@@ -176,6 +184,7 @@ export function getInstanceFromNode(node: Node): Fiber | null {
176184 tag === HostComponent ||
177185 tag === HostText ||
178186 tag === SuspenseComponent ||
187+ tag === ActivityComponent ||
179188 tag === HostHoistable ||
180189 tag === HostSingleton ||
181190 tag === HostRoot
@@ -211,15 +220,17 @@ export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
211220}
212221
213222export function getFiberCurrentPropsFromNode (
214- node : Container | Instance | TextInstance | SuspenseInstance ,
223+ node :
224+ | Container
225+ | Instance
226+ | TextInstance
227+ | SuspenseInstance
228+ | ActivityInstance ,
215229) : Props {
216230 return ( node : any ) [ internalPropsKey ] || null ;
217231}
218232
219- export function updateFiberProps (
220- node : Instance | TextInstance | SuspenseInstance ,
221- props : Props ,
222- ) : void {
233+ export function updateFiberProps ( node : Instance , props : Props ) : void {
223234 ( node : any ) [ internalPropsKey ] = props ;
224235}
225236
0 commit comments