mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
parent
bd89ce53a9
commit
f0057b101e
@ -274,10 +274,7 @@ function doWatch(
|
|||||||
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE
|
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE
|
||||||
// overwrite default run
|
// overwrite default run
|
||||||
watcher.run = () => {
|
watcher.run = () => {
|
||||||
if (
|
if (!watcher.active) {
|
||||||
!watcher.active &&
|
|
||||||
!(flush === 'pre' && instance && instance._isBeingDestroyed)
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (cb) {
|
if (cb) {
|
||||||
|
@ -542,7 +542,7 @@ describe('api: watch', () => {
|
|||||||
expect(cb).not.toHaveBeenCalled()
|
expect(cb).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fire on component unmount w/ flush: pre', async () => {
|
it('should not fire on component unmount w/ flush: pre', async () => {
|
||||||
const toggle = ref(true)
|
const toggle = ref(true)
|
||||||
const cb = vi.fn()
|
const cb = vi.fn()
|
||||||
const Comp = {
|
const Comp = {
|
||||||
@ -560,7 +560,7 @@ describe('api: watch', () => {
|
|||||||
expect(cb).not.toHaveBeenCalled()
|
expect(cb).not.toHaveBeenCalled()
|
||||||
toggle.value = false
|
toggle.value = false
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect(cb).toHaveBeenCalledTimes(1)
|
expect(cb).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
// vuejs/core#1763
|
// vuejs/core#1763
|
||||||
|
Loading…
Reference in New Issue
Block a user