fix(watch): flush:pre watchers should not fire if state change causes

owner component to unmount

fix #2291
This commit is contained in:
Evan You
2022-08-15 19:00:55 +08:00
parent a95554d35c
commit 78c199d6db
5 changed files with 68 additions and 142 deletions

View File

@@ -509,7 +509,8 @@ describe('api: watch', () => {
expect(cb).not.toHaveBeenCalled()
})
it('should fire on component unmount w/ flush: pre', async () => {
// #2291
it('should not fire on component unmount w/ flush: pre', async () => {
const toggle = ref(true)
const cb = jest.fn()
const Comp = {
@@ -527,7 +528,7 @@ describe('api: watch', () => {
expect(cb).not.toHaveBeenCalled()
toggle.value = false
await nextTick()
expect(cb).toHaveBeenCalledTimes(1)
expect(cb).not.toHaveBeenCalled()
})
// #1763