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

$scopedSlots is empty until render() #11714

Open
KaelWD opened this issue Oct 7, 2020 · 1 comment · May be fixed by #11726
Open

$scopedSlots is empty until render() #11714

KaelWD opened this issue Oct 7, 2020 · 1 comment · May be fixed by #11726

Comments

@KaelWD
Copy link
Contributor

KaelWD commented Oct 7, 2020

Version

2.6.11

Reproduction link

https://codepen.io/kaelwd/pen/rNLNYGL?editors=1011

Steps to reproduce

Open the console

What is expected?

"ScopedComponent beforeMount" true to be logged

What is actually happening?

"ScopedComponent beforeMount" false


This was discovered in vuetify: vuetifyjs/vuetify#11533 (comment)

The real setup is a watcher on a computed property that depends on $slots. The watcher is called before mount to get an initial value, causing the computed property to be executed and return an incorrect value.

Minimal example with the watcher if that helps: https://codepen.io/kaelwd/pen/vYKYWbV?editors=1010

This works as expected in vue 3: https://codepen.io/kaelwd/pen/gOMOXoB?editors=1011

The bug seems to have existed since scoped slots were introduced in v2.1, but it wasn't a problem here until v2.6 when scoped slots started being used everywhere with v-slot

@shadowings-zy
Copy link
Contributor

shadowings-zy commented Oct 17, 2020

Hello, I fix this bug in PR #11726 .
In before mount, Vue2 will always create an empty object when init render. And in this PR, it will normalize scoped slots when parent vnode is not undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants