@@ -132,7 +132,6 @@ import {
132
132
Snapshot ,
133
133
Callback ,
134
134
Passive ,
135
- // TODO (effects) Maybe get rid of this in favor of new subtreeTag?
136
135
PassiveUnmountPendingDev ,
137
136
Incomplete ,
138
137
HostEffectMask ,
@@ -2181,8 +2180,6 @@ function commitRootImpl(root, renderPriorityLevel) {
2181
2180
return null ;
2182
2181
} ) ;
2183
2182
}
2184
- } else {
2185
- // TODO (effects) Clear deletion arrays
2186
2183
}
2187
2184
2188
2185
// Tell Scheduler to yield at the end of the frame, so the browser has an
@@ -2216,8 +2213,6 @@ function commitRootImpl(root, renderPriorityLevel) {
2216
2213
rootWithPendingPassiveEffects = root ;
2217
2214
pendingPassiveEffectsLanes = lanes ;
2218
2215
pendingPassiveEffectsRenderPriority = renderPriorityLevel ;
2219
- } else {
2220
- // TODO (effects) Detach sibling pointers for deleted Fibers
2221
2216
}
2222
2217
2223
2218
// Read this again, since an effect might have updated it
@@ -2418,7 +2413,8 @@ function commitMutationEffects(
2418
2413
renderPriorityLevel ,
2419
2414
) ;
2420
2415
2421
- // TODO (effects) Clear deletions array if there are no pending passive effects.
2416
+ // TODO (effects) Detach sibling pointers for deleted Fibers
2417
+ // TODO (effects) Clear deletion arrays
2422
2418
}
2423
2419
2424
2420
if ( fiber . child !== null ) {
@@ -2773,53 +2769,49 @@ function flushPassiveMountEffectsImpl(fiber: Fiber): void {
2773
2769
}
2774
2770
}
2775
2771
2776
- function flushPassiveUnmountEffects (
2777
- firstChild : Fiber ,
2778
- isDeletion : boolean ,
2779
- ) : void {
2772
+ function flushPassiveUnmountEffects ( firstChild : Fiber ) : void {
2780
2773
let fiber = firstChild ;
2781
2774
while ( fiber !== null ) {
2782
2775
const deletions = fiber . deletions ;
2783
2776
if ( deletions !== null ) {
2784
2777
for ( let i = 0 ; i < deletions . length ; i ++ ) {
2785
2778
const fiberToDelete = deletions [ i ] ;
2786
- // TODO (effects) This probably won't work because effectsTag and subtreeTag won't be set
2787
- // correctly for nested Fibers; we need to traverse the whole tree then which sucks.
2788
- // We should update commitUnmount() to handle this when we call enqueuePassive blah.
2789
- // TODO (effects) This is probably a change in deletion ordering (recursing subtrees this way)
2790
- // but that presumably doesn't matter so long as we process all deletions before creations?
2791
- flushPassiveUnmountEffects ( fiberToDelete , true ) ;
2779
+ // If this fiber (or anything below it) has passive effects then traverse the subtree.
2780
+ const primaryEffectTag = fiberToDelete . effectTag & ( Passive | Update ) ;
2781
+ const primarySubtreeTag = fiberToDelete . subtreeTag & PassiveSubtreeTag ;
2782
+ if (
2783
+ primarySubtreeTag !== NoSubtreeTag ||
2784
+ primaryEffectTag !== NoEffect
2785
+ ) {
2786
+ flushPassiveUnmountEffects ( fiberToDelete ) ;
2787
+ }
2792
2788
}
2793
2789
}
2794
2790
2795
2791
const didBailout =
2796
2792
fiber . alternate !== null && fiber . alternate . child === fiber . child ;
2797
- if ( fiber . child !== null && ! didBailout ) {
2798
- // TODO (effects) See above
2799
- //const primarySubtreeTag = fiber.subtreeTag & Deletion;
2800
- //if (primarySubtreeTag !== NoEffect) {
2801
- flushPassiveUnmountEffects ( fiber . child , isDeletion ) ;
2802
- //}
2803
- }
2804
- // TODO (effects) Are we traversing extra here? Maybe we won't need this check
2805
- // here once we stop over traversing.
2806
- const primarySubtreeTag =
2807
- fiber . return === null ||
2808
- ( fiber . return . subtreeTag & PassiveSubtreeTag ) !== NoSubtreeTag ;
2809
- if (
2810
- isDeletion ||
2811
- ( ( fiber . effectTag & Update ) !== NoEffect && primarySubtreeTag )
2812
- ) {
2813
- switch ( fiber . tag ) {
2814
- case FunctionComponent :
2815
- case ForwardRef :
2816
- case SimpleMemoComponent :
2817
- case Block : {
2818
- // TODO (effects) See above
2819
- //const primaryEffectTag = fiber.effectTag & Passive;
2820
- //if (primaryEffectTag !== NoEffect) {
2793
+ if ( ! didBailout ) {
2794
+ const child = fiber . child ;
2795
+ if ( child !== null ) {
2796
+ // If any children have passive effects then traverse the subtree.
2797
+ // Note that this requires checking subtreeTag of the current Fiber,
2798
+ // rather than the subtreeTag/effectsTag of the first child,
2799
+ // since that would not cover passive effects in siblings.
2800
+ const primarySubtreeTag = fiber . subtreeTag & PassiveSubtreeTag ;
2801
+ if ( primarySubtreeTag !== NoSubtreeTag ) {
2802
+ flushPassiveUnmountEffects ( child ) ;
2803
+ }
2804
+ }
2805
+ }
2806
+
2807
+ switch ( fiber . tag ) {
2808
+ case FunctionComponent :
2809
+ case ForwardRef :
2810
+ case SimpleMemoComponent :
2811
+ case Block : {
2812
+ const primaryEffectTag = fiber . effectTag & ( Passive | Update ) ;
2813
+ if ( primaryEffectTag !== NoEffect ) {
2821
2814
flushPassiveUnmountEffectsImpl ( fiber ) ;
2822
- //}
2823
2815
}
2824
2816
}
2825
2817
}
@@ -2939,7 +2931,7 @@ function flushPassiveEffectsImpl() {
2939
2931
// e.g. a destroy function in one component may unintentionally override a ref
2940
2932
// value set by a create function in another component.
2941
2933
// Layout effects have the same constraint.
2942
- flushPassiveUnmountEffects ( root . current , false ) ;
2934
+ flushPassiveUnmountEffects ( root . current ) ;
2943
2935
flushPassiveMountEffects ( root . current ) ;
2944
2936
2945
2937
// TODO (effects) Detach sibling pointers for deleted Fibers
0 commit comments