Skip to content

Commit 5bfcad1

Browse files
committed
fix(suspense): should discard unmount effects of invalidated pending branch
1 parent 49bb447 commit 5bfcad1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/runtime-core/__tests__/components/Suspense.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ describe('Suspense', () => {
380380
await Promise.all(deps)
381381
await nextTick()
382382
expect(serializeInner(root)).toBe(`<!---->`)
383-
// should discard effects (except for unmount)
384-
expect(calls).toEqual(['unmounted'])
383+
// should discard effects
384+
expect(calls).toEqual([])
385385
})
386386

387387
test('unmount suspense after resolve', async () => {

packages/runtime-core/src/components/Suspense.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ function patchSuspense(
201201
suspense.isHydrating = false
202202
suspense.activeBranch = pendingBranch
203203
} else {
204-
unmount(pendingBranch, parentComponent, null)
204+
unmount(pendingBranch, parentComponent, suspense)
205205
}
206206
// increment pending ID. this is used to invalidate async callbacks
207207
// reset suspense state
208208
suspense.deps = 0
209+
// discard effects from pending branch
209210
suspense.effects.length = 0
210211
// discard previous container
211212
suspense.hiddenContainer = createElement('div')

0 commit comments

Comments
 (0)