@@ -17,10 +17,10 @@ import type {
17
17
} from './ReactFiberHostConfig' ;
18
18
import type { Fiber } from './ReactInternalTypes' ;
19
19
import type { FiberRoot } from './ReactInternalTypes' ;
20
- import type { LanePriority , Lanes } from './ReactFiberLane.old ' ;
21
- import type { SuspenseState } from './ReactFiberSuspenseComponent.old ' ;
22
- import type { UpdateQueue } from './ReactUpdateQueue.old ' ;
23
- import type { FunctionComponentUpdateQueue } from './ReactFiberHooks.old ' ;
20
+ import type { LanePriority , Lanes } from './ReactFiberLane.new ' ;
21
+ import type { SuspenseState } from './ReactFiberSuspenseComponent.new ' ;
22
+ import type { UpdateQueue } from './ReactUpdateQueue.new ' ;
23
+ import type { FunctionComponentUpdateQueue } from './ReactFiberHooks.new ' ;
24
24
import type { Wakeable } from 'shared/ReactTypes' ;
25
25
import type { OffscreenState } from './ReactFiberOffscreenComponent' ;
26
26
import type { HookFlags } from './ReactHookEffectTags' ;
@@ -35,7 +35,11 @@ import {
35
35
enableSuspenseCallback ,
36
36
enableScopeAPI ,
37
37
enableStrictEffects ,
38
+ < << << << current
38
39
enableStrongMemoryCleanup ,
40
+ = === ===
41
+ enableDetachOldChildList ,
42
+ > >>> >>> patched
39
43
} from 'shared/ReactFeatureFlags' ;
40
44
import {
41
45
FunctionComponent ,
@@ -87,18 +91,18 @@ import {
87
91
setCurrentFiber as setCurrentDebugFiberInDEV ,
88
92
} from './ReactCurrentFiber' ;
89
93
90
- import { onCommitUnmount } from './ReactFiberDevToolsHook.old ' ;
91
- import { resolveDefaultProps } from './ReactFiberLazyComponent.old ' ;
94
+ import { onCommitUnmount } from './ReactFiberDevToolsHook.new ' ;
95
+ import { resolveDefaultProps } from './ReactFiberLazyComponent.new ' ;
92
96
import {
93
97
isCurrentUpdateNested ,
94
98
getCommitTime ,
95
99
recordLayoutEffectDuration ,
96
100
startLayoutEffectTimer ,
97
101
recordPassiveEffectDuration ,
98
102
startPassiveEffectTimer ,
99
- } from './ReactProfilerTimer.old ' ;
103
+ } from './ReactProfilerTimer.new ' ;
100
104
import { ProfileMode } from './ReactTypeOfMode' ;
101
- import { commitUpdateQueue } from './ReactUpdateQueue.old ' ;
105
+ import { commitUpdateQueue } from './ReactUpdateQueue.new ' ;
102
106
import {
103
107
getPublicInstance ,
104
108
supportsMutation ,
@@ -134,14 +138,14 @@ import {
134
138
resolveRetryWakeable ,
135
139
markCommitTimeOfFallback ,
136
140
enqueuePendingPassiveProfilerEffect ,
137
- } from './ReactFiberWorkLoop.old ' ;
141
+ } from './ReactFiberWorkLoop.new ' ;
138
142
import {
139
143
NoFlags as NoHookEffect ,
140
144
HasEffect as HookHasEffect ,
141
145
Layout as HookLayout ,
142
146
Passive as HookPassive ,
143
147
} from './ReactHookEffectTags' ;
144
- import { didWarnAboutReassigningProps } from './ReactFiberBeginWork.old ' ;
148
+ import { didWarnAboutReassigningProps } from './ReactFiberBeginWork.new ' ;
145
149
import { doesFiberContain } from './ReactFiberTreeReflection' ;
146
150
147
151
let didWarnAboutUndefinedSnapshotBeforeUpdate : Set < mixed > | null = null ;
@@ -2323,6 +2327,33 @@ function commitPassiveUnmountEffects_begin() {
2323
2327
detachFiberAfterEffects ( alternate ) ;
2324
2328
}
2325
2329
}
2330
+
2331
+ if ( enableDetachOldChildList ) {
2332
+ // A fiber was deleted from this parent fiber, but it's still part of
2333
+ // the previous (alternate) parent fiber's list of children. Because
2334
+ // children are a linked list, an earlier sibling that's still alive
2335
+ // will be connected to the deleted fiber via its `alternate`:
2336
+ //
2337
+ // live fiber
2338
+ // --alternate--> previous live fiber
2339
+ // --sibling--> deleted fiber
2340
+ //
2341
+ // We can't disconnect `alternate` on nodes that haven't been deleted
2342
+ // yet, but we can disconnect the `sibling` and `child` pointers.
2343
+ const previousFiber = fiber . alternate ;
2344
+ if ( previousFiber !== null ) {
2345
+ let detachedChild = previousFiber . child ;
2346
+ if ( detachedChild !== null ) {
2347
+ previousFiber . child = null ;
2348
+ do {
2349
+ const detachedSibling = detachedChild . sibling ;
2350
+ detachedChild . sibling = null ;
2351
+ detachedChild = detachedSibling ;
2352
+ } while ( detachedChild !== null ) ;
2353
+ }
2354
+ }
2355
+ }
2356
+
2326
2357
nextEffect = fiber ;
2327
2358
}
2328
2359
}
0 commit comments