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

Default slot content should not be evaluated when the parent is providing it #10224

Closed
Rolanddoda opened this issue Jul 3, 2019 · 2 comments · Fixed by #12014
Closed

Default slot content should not be evaluated when the parent is providing it #10224

Rolanddoda opened this issue Jul 3, 2019 · 2 comments · Fixed by #12014

Comments

@Rolanddoda
Copy link

Rolanddoda commented Jul 3, 2019

Version

2.6.10

Reproduction link

https://codesandbox.io/s/kk445knpx3

Steps to reproduce

In the Child.vue we have a slot with a default slot content. In the Parent.vue we override the default content of the child.

What is expected?

IMO the content of the slot in child component should not be evaluated since the content provided from the parent will be used.

What is actually happening?

The content of the parent it renders which is what I expect.

The default content of the Child.vue it's evaluated even if it not renders. That's why you see in the console: Cannot read property 'length' of null


Maybe that's not a bug and instead it's the intentional behavior, but it doesn't make sense to me, to evaluate something that will not render.

@posva posva changed the title Default slot content should not be evaluated when the parent replaces it Default slot content should not be evaluated when the parent is providing it Jul 3, 2019
@posva
Copy link
Member

posva commented Jul 3, 2019

I would say this is a bug as we should be able to pass a function to the slot function (_t) so the default slot content is only evaluated if no slot is provided.

I thought a workaround would be using a v-for to make it lazy, but it doesn't work

@Rolanddoda
Copy link
Author

Thanks for the quick response @posva .

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