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
|
||||
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 }
|
||||
)
|
||||
|
|
|
@ -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
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue