Skip to content

Commit

Permalink
fix(suspense): should discard unmount effects of invalidated pending …
Browse files Browse the repository at this point in the history
…branch
  • Loading branch information
yyx990803 committed Sep 18, 2020
1 parent 49bb447 commit 5bfcad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-core/__tests__/components/Suspense.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ describe('Suspense', () => {
await Promise.all(deps)
await nextTick()
expect(serializeInner(root)).toBe(`<!---->`)
// should discard effects (except for unmount)
expect(calls).toEqual(['unmounted'])
// should discard effects
expect(calls).toEqual([])
})

test('unmount suspense after resolve', async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ function patchSuspense(
suspense.isHydrating = false
suspense.activeBranch = pendingBranch
} else {
unmount(pendingBranch, parentComponent, null)
unmount(pendingBranch, parentComponent, suspense)
}
// increment pending ID. this is used to invalidate async callbacks
// reset suspense state
suspense.deps = 0
// discard effects from pending branch
suspense.effects.length = 0
// discard previous container
suspense.hiddenContainer = createElement('div')
Expand Down

0 comments on commit 5bfcad1

Please sign in to comment.