diff --git a/src/v3/apiWatch.ts b/src/v3/apiWatch.ts index 7fe5eeb9d..141a58eb6 100644 --- a/src/v3/apiWatch.ts +++ b/src/v3/apiWatch.ts @@ -274,10 +274,7 @@ function doWatch( let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE // overwrite default run watcher.run = () => { - if ( - !watcher.active && - !(flush === 'pre' && instance && instance._isBeingDestroyed) - ) { + if (!watcher.active) { return } if (cb) { diff --git a/test/unit/features/v3/apiWatch.spec.ts b/test/unit/features/v3/apiWatch.spec.ts index 0206e8df3..c92bc150a 100644 --- a/test/unit/features/v3/apiWatch.spec.ts +++ b/test/unit/features/v3/apiWatch.spec.ts @@ -542,7 +542,7 @@ describe('api: watch', () => { 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 cb = vi.fn() const Comp = { @@ -560,7 +560,7 @@ describe('api: watch', () => { expect(cb).not.toHaveBeenCalled() toggle.value = false await nextTick() - expect(cb).toHaveBeenCalledTimes(1) + expect(cb).not.toHaveBeenCalled() }) // vuejs/core#1763