core icon indicating copy to clipboard operation
core copied to clipboard

fix(runtime-core): watching multiple values - handle `undefined` as initial values (fix: #5032)

Open LinusBorg opened this issue 3 years ago • 2 comments

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

LinusBorg avatar Dec 03 '21 20:12 LinusBorg

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.

nickrum avatar Jun 14 '22 15:06 nickrum

Deploy Preview for vuejs-coverage failed.

Name Link
Latest commit 1bff8c112555d4bfa51d4c4a5a774b8657d93e27
Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/633fff8c02245c0008f04572

netlify[bot] avatar Oct 07 '22 10:10 netlify[bot]

ant-design-vue fixed this https://github.com/vueComponent/ant-design-vue/pull/6085

zhangbowy avatar Nov 09 '22 13:11 zhangbowy