Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watch handler not executed immediately if source returns undefined #683

Closed
jacekkarczmarczyk opened this issue Feb 1, 2020 · 1 comment · Fixed by #687
Closed

watch handler not executed immediately if source returns undefined #683

jacekkarczmarczyk opened this issue Feb 1, 2020 · 1 comment · Fixed by #687
Labels
🐞 bug Something isn't working

Comments

@jacekkarczmarczyk
Copy link
Contributor

Version

3.0.0-alpha.4

Reproduction link

https://codepen.io/jkarczm/pen/ZEYgEXd?editors=0011

Steps to reproduce

watch(() => null, () => console.log('null watched'))
watch(() => undefined, () => console.log('undefined watched'))

What is expected?

null watched and undefined watched in console

What is actually happening?

only null watched in console

@sys-keys
Copy link

sys-keys commented Feb 1, 2020

https://github.com/vuejs/vue-next/blob/74cb207c2296c9865ba42e1539077f4bb68929f0/packages/runtime-core/src/apiWatch.ts#L156-L164

Seems to be caused by setting oldValue before first run to undefined, then checking against the result of the getter which is also undefined so no runs will take place until the value is changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working
Projects
None yet
3 participants