fix(watch): post flush watchers should not fire when component is unmounted

fix #1603
This commit is contained in:
Evan You
2020-07-17 11:17:29 -04:00
parent 024a8f10f5
commit 341b30c961
4 changed files with 100 additions and 39 deletions

View File

@@ -170,7 +170,7 @@ describe('Suspense', () => {
})
const count = ref(0)
watch(count, v => {
watch(count, () => {
calls.push('watch callback')
})
count.value++ // trigger the watcher now
@@ -367,7 +367,7 @@ describe('Suspense', () => {
await nextTick()
expect(serializeInner(root)).toBe(`<!---->`)
// should discard effects (except for immediate ones)
expect(calls).toEqual(['immediate effect', 'watch callback', 'unmounted'])
expect(calls).toEqual(['immediate effect', 'unmounted'])
})
test('unmount suspense after resolve', async () => {