diff --git a/packages/runtime-core/__tests__/apiWatch.spec.ts b/packages/runtime-core/__tests__/apiWatch.spec.ts index c9db3657367..029146b5205 100644 --- a/packages/runtime-core/__tests__/apiWatch.spec.ts +++ b/packages/runtime-core/__tests__/apiWatch.spec.ts @@ -183,10 +183,10 @@ describe('api: watch', () => { let called = false watch( [a, b], - (newVal, oldVal) => { + ([newA, newB], [oldA, oldB]) => { called = true - expect(newVal).toMatchObject([undefined, undefined]) - expect(oldVal).toBeUndefined() + expect([newA, newB]).toMatchObject([undefined, undefined]) + expect([oldA, oldB]).toMatchObject([undefined, undefined]) }, { immediate: true } ) diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index 180843cf745..99445be77d2 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/packages/runtime-core/src/apiWatch.ts @@ -335,7 +335,7 @@ function doWatch( // pass undefined as the old value when it's changed for the first time oldValue === INITIAL_WATCHER_VALUE || (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE) - ? undefined + ? [] : oldValue, onCleanup ])