core
core copied to clipboard
fix(runtime-core): watching multiple values - handle `undefined` as initial values (fix: #5032)
We currently have an empty array as the intial oldValue for a watcher that watches multiple values.
This does fail for an edge case where we watch multiple values and all of them are initially undefined, and trigger the watcher immediately.
We can solve this by settting the initial oldValue to an array filled with INITIAL_WATCHER_VALUE
fix: #5032
I ran into the exact same issue this PR is fixing. While investigationg the issue, in noticed that, in addition to the original issue, the wrong value is passed to callWithAsyncErrorHandling() when using an immediate watcher with multiple sources over here.
Replacing oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue with something like (isMultiSource ? (oldValue as []).every((v) => v === INITIAL_WATCHER_VALUE) : oldValue === INITIAL_WATCHER_VALUE) ? undefined : oldValue should fix the issue.
It's a pretty minor issue, so I'm wondering whether this would warrant a separate PR or if you could simply include the fix in your PR.
Deploy Preview for vuejs-coverage failed.
| Name | Link |
|---|---|
| Latest commit | 1bff8c112555d4bfa51d4c4a5a774b8657d93e27 |
| Latest deploy log | https://app.netlify.com/sites/vuejs-coverage/deploys/633fff8c02245c0008f04572 |
ant-design-vue fixed this https://github.com/vueComponent/ant-design-vue/pull/6085