@@ -35,6 +35,7 @@ import {
3535 enableLegacyHidden ,
3636 enableSuspenseCallback ,
3737 enableScopeAPI ,
38+ enablePersistedModeClonedFlag ,
3839 enableProfilerTimer ,
3940 enableCache ,
4041 enableTransitionTracing ,
@@ -83,6 +84,7 @@ import {
8384 Snapshot ,
8485 ChildDeletion ,
8586 StaticMask ,
87+ MutationMask ,
8688 Passive ,
8789 ForceClientRender ,
8890 MaySuspendCommit ,
@@ -187,7 +189,7 @@ function markUpdate(workInProgress: Fiber) {
187189 * it received an update that requires a clone of the tree above.
188190 */
189191function markCloned ( workInProgress : Fiber ) {
190- if ( supportsPersistence ) {
192+ if ( supportsPersistence && enablePersistedModeClonedFlag ) {
191193 workInProgress . flags |= Cloned ;
192194 }
193195}
@@ -209,9 +211,12 @@ function doesRequireClone(current: null | Fiber, completedWork: Fiber) {
209211 // then we only have to check the `completedWork.subtreeFlags`.
210212 let child = completedWork . child ;
211213 while ( child !== null ) {
214+ const checkedFlags = enablePersistedModeClonedFlag
215+ ? Cloned | Visibility | Placement
216+ : MutationMask ;
212217 if (
213- ( child . flags & ( Cloned | Visibility | Placement ) ) !== NoFlags ||
214- ( child . subtreeFlags & ( Cloned | Visibility | Placement ) ) !== NoFlags
218+ ( child . flags & checkedFlags ) !== NoFlags ||
219+ ( child . subtreeFlags & checkedFlags ) !== NoFlags
215220 ) {
216221 return true ;
217222 }
@@ -498,7 +503,14 @@ function updateHostComponent(
498503 markUpdate ( workInProgress ) ;
499504 }
500505 workInProgress . stateNode = newInstance ;
501- if ( requiresClone && ! passChildrenWhenCloningPersistedNodes ) {
506+ if ( ! requiresClone ) {
507+ if ( ! enablePersistedModeClonedFlag ) {
508+ // If there are no other effects in this tree, we need to flag this node as having one.
509+ // Even though we're not going to use it for anything.
510+ // Otherwise parents won't know that there are new children to propagate upwards.
511+ markUpdate ( workInProgress ) ;
512+ }
513+ } else if ( ! passChildrenWhenCloningPersistedNodes ) {
502514 // If children have changed, we have to add them all to the set.
503515 appendAllChildren (
504516 newInstance ,
@@ -665,6 +677,11 @@ function updateHostText(
665677 currentHostContext ,
666678 workInProgress ,
667679 ) ;
680+ if ( ! enablePersistedModeClonedFlag ) {
681+ // We'll have to mark it as having an effect, even though we won't use the effect for anything.
682+ // This lets the parents know that at least one of their children has changed.
683+ markUpdate ( workInProgress ) ;
684+ }
668685 } else {
669686 workInProgress . stateNode = current . stateNode ;
670687 }
0 commit comments