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

this.$slots contents differ at same lifecycle stage based on slot syntax #11854

Closed
tehciolo opened this issue Jan 7, 2021 · 1 comment
Closed

Comments

@tehciolo
Copy link

tehciolo commented Jan 7, 2021

Version

2.6.11

Reproduction link

https://codepen.io/tehciolo/pen/zYKaRQK

Steps to reproduce

Check console

What is expected?

I would expect this.$slots to be populated at the same stage for both syntaxes (old and new).

What is actually happening?

this.$slots is populated only starting with mounted when using v-slot syntax


This issue seems related to #9458

@posva
Copy link
Member

posva commented Jan 7, 2021

This is expected because both syntaxes were different and they are unified only in Vue 3 to avoid breaking changes in Vue 2. More details have been given in similar issues, tldr is: $slots directly contains vnode while $scopedSlots contains functions to create those vnodes, slot="name" uses $slots while v-slot uses $scopedSlots. $slots of scoped slots are only available after mounting when the vnodes have been created. If for some reason the slot is not being rendered (e.g. with a v-if), $slots will stay empy

@posva posva closed this as completed Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants