@@ -40,6 +40,7 @@ import {
40
40
popMutationContext ,
41
41
pushMutationContext ,
42
42
viewTransitionMutationContext ,
43
+ trackHostMutation ,
43
44
} from './ReactFiberMutationTracking' ;
44
45
import {
45
46
MutationMask ,
@@ -432,6 +433,7 @@ function recursivelyInsertNewFiber(
432
433
// For insertions we don't need to clone. It's already new state node.
433
434
if ( visitPhase !== INSERT_APPEARING_PAIR ) {
434
435
appendChild ( hostParentClone , instance ) ;
436
+ trackHostMutation ( ) ;
435
437
recursivelyInsertNew (
436
438
finishedWork ,
437
439
instance ,
@@ -461,6 +463,7 @@ function recursivelyInsertNewFiber(
461
463
// For insertions we don't need to clone. It's already new state node.
462
464
if ( visitPhase !== INSERT_APPEARING_PAIR ) {
463
465
appendChild ( hostParentClone , textInstance ) ;
466
+ trackHostMutation ( ) ;
464
467
}
465
468
break ;
466
469
}
@@ -586,6 +589,7 @@ function recursivelyInsertClonesFromExistingTree(
586
589
}
587
590
if ( visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE ) {
588
591
unhideInstance ( clone , child . memoizedProps ) ;
592
+ trackHostMutation ( ) ;
589
593
}
590
594
break ;
591
595
}
@@ -601,6 +605,7 @@ function recursivelyInsertClonesFromExistingTree(
601
605
appendChild ( hostParentClone , clone ) ;
602
606
if ( visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE ) {
603
607
unhideTextInstance ( clone , child . memoizedProps ) ;
608
+ trackHostMutation ( ) ;
604
609
}
605
610
break ;
606
611
}
@@ -690,6 +695,10 @@ function recursivelyInsertClones(
690
695
for ( let i = 0 ; i < deletions . length ; i ++ ) {
691
696
const childToDelete = deletions [ i ] ;
692
697
trackEnterViewTransitions ( childToDelete ) ;
698
+ // Normally we would only mark something as triggering a mutation if there was
699
+ // actually a HostInstance below here. If this tree didn't contain a HostInstances
700
+ // we shouldn't trigger a mutation even though a virtual component was deleted.
701
+ trackHostMutation ( ) ;
693
702
}
694
703
}
695
704
@@ -812,6 +821,7 @@ function insertDestinationClonesOfFiber(
812
821
clone = cloneMutableInstance ( instance , true ) ;
813
822
if ( finishedWork . flags & ContentReset ) {
814
823
resetTextContent ( clone ) ;
824
+ trackHostMutation ( ) ;
815
825
}
816
826
} else {
817
827
// If we have children we'll clone them as we walk the tree so we just
@@ -836,6 +846,7 @@ function insertDestinationClonesOfFiber(
836
846
) ;
837
847
appendChild ( hostParentClone , clone ) ;
838
848
unhideInstance ( clone , finishedWork . memoizedProps ) ;
849
+ trackHostMutation ( ) ;
839
850
} else {
840
851
recursivelyInsertClones ( finishedWork , clone , null , visitPhase ) ;
841
852
appendChild ( hostParentClone , clone ) ;
@@ -862,10 +873,12 @@ function insertDestinationClonesOfFiber(
862
873
const newText : string = finishedWork . memoizedProps ;
863
874
const oldText : string = current . memoizedProps ;
864
875
commitTextUpdate ( clone , newText , oldText ) ;
876
+ trackHostMutation ( ) ;
865
877
}
866
878
appendChild ( hostParentClone , clone ) ;
867
879
if ( visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE ) {
868
880
unhideTextInstance ( clone , finishedWork . memoizedProps ) ;
881
+ trackHostMutation ( ) ;
869
882
}
870
883
break ;
871
884
}
@@ -896,6 +909,10 @@ function insertDestinationClonesOfFiber(
896
909
} else if ( current !== null && current . memoizedState === null ) {
897
910
// Was previously mounted as visible but is now hidden.
898
911
trackEnterViewTransitions ( current ) ;
912
+ // Normally we would only mark something as triggering a mutation if there was
913
+ // actually a HostInstance below here. If this tree didn't contain a HostInstances
914
+ // we shouldn't trigger a mutation even though a virtual component was hidden.
915
+ trackHostMutation ( ) ;
899
916
}
900
917
break ;
901
918
}
0 commit comments