From: Evan You Date: Fri, 18 Sep 2020 03:49:06 +0000 (-0400) Subject: fix(suspense): should discard unmount effects of invalidated pending branch X-Git-Tag: v3.0.0-rc.13~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bfcad155b444b2f7ffaac171c1f61bc23909287;p=thirdparty%2Fvuejs%2Fcore.git fix(suspense): should discard unmount effects of invalidated pending branch --- diff --git a/packages/runtime-core/__tests__/components/Suspense.spec.ts b/packages/runtime-core/__tests__/components/Suspense.spec.ts index dd7d67bc90..c6ab0f3fa3 100644 --- a/packages/runtime-core/__tests__/components/Suspense.spec.ts +++ b/packages/runtime-core/__tests__/components/Suspense.spec.ts @@ -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 () => { diff --git a/packages/runtime-core/src/components/Suspense.ts b/packages/runtime-core/src/components/Suspense.ts index 16204b6d0e..288139609a 100644 --- a/packages/runtime-core/src/components/Suspense.ts +++ b/packages/runtime-core/src/components/Suspense.ts @@ -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')