mirror of https://github.com/vuejs/core.git
fix(watch): ensure oldValue in multi-source watcher is always an array
fix #7070
This commit is contained in:
parent
d33292dd47
commit
23e85e21a5
|
@ -183,10 +183,10 @@ describe('api: watch', () => {
|
||||||
let called = false
|
let called = false
|
||||||
watch(
|
watch(
|
||||||
[a, b],
|
[a, b],
|
||||||
(newVal, oldVal) => {
|
([newA, newB], [oldA, oldB]) => {
|
||||||
called = true
|
called = true
|
||||||
expect(newVal).toMatchObject([undefined, undefined])
|
expect([newA, newB]).toMatchObject([undefined, undefined])
|
||||||
expect(oldVal).toBeUndefined()
|
expect([oldA, oldB]).toMatchObject([undefined, undefined])
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
|
|
|
@ -335,7 +335,7 @@ function doWatch(
|
||||||
// pass undefined as the old value when it's changed for the first time
|
// pass undefined as the old value when it's changed for the first time
|
||||||
oldValue === INITIAL_WATCHER_VALUE ||
|
oldValue === INITIAL_WATCHER_VALUE ||
|
||||||
(isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
|
(isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
|
||||||
? undefined
|
? []
|
||||||
: oldValue,
|
: oldValue,
|
||||||
onCleanup
|
onCleanup
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue