diff --git a/src/apis/watch.ts b/src/apis/watch.ts index 83522aed..91f68c3f 100644 --- a/src/apis/watch.ts +++ b/src/apis/watch.ts @@ -341,7 +341,11 @@ function createWatcher( } const applyCb = (n: any, o: any) => { - if (isMultiSource && n.every((v: any, i: number) => Object.is(v, o[i]))) + if ( + !deep && + isMultiSource && + n.every((v: any, i: number) => Object.is(v, o[i])) + ) return // cleanup before running cb again runCleanup() diff --git a/test/v3/runtime-core/apiWatch.spec.ts b/test/v3/runtime-core/apiWatch.spec.ts index d1f440a1..f71bcd05 100644 --- a/test/v3/runtime-core/apiWatch.spec.ts +++ b/test/v3/runtime-core/apiWatch.spec.ts @@ -572,4 +572,14 @@ describe('api: watch', () => { await nextTick() expect(dummy).toEqual([1, 2]) }) + + // #805 #807 + it('watching sources: [ref<[]>] w/ deep', async () => { + const foo = ref([1]) + const cb = jest.fn() + watch([foo], cb, { deep: true }) + foo.value.push(2) + await nextTick() + expect(cb).toBeCalledTimes(1) + }) })