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

component content unexpectedly rendered #9877

Closed
FranckFreiburger opened this Issue Apr 15, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@FranckFreiburger
Copy link

FranckFreiburger commented Apr 15, 2019

Version

2.6.10

Reproduction link

https://jsfiddle.net/r0gkjw1p/1/

Steps to reproduce

just run the fiddle demo

What is expected?

Since parent component (<foo>) renders nothing,
I expect bar() to not be called.

What is actually happening?

bar() is unexpectedly called


This is a simplified test case.
This situation is much more annoying when using SSR + browser-only-library + vue-no-ssr.
This ends up with JS code designed for client-side to be called server-side despite of using no-ssr mechanism

@posva

This comment has been minimized.

Copy link
Member

posva commented Apr 15, 2019

as you are using a regular slot, this one is rendered in the parent template then passed to the component, using a scoped slot would prevent it as it won't be rendered if it isn't used inside the component. Wrapping it in a <template v-slot></template>popp or putting v-slot in the foo component will prevent it from eagerly render.

This probably won't be a problem for v3 though as slots will be unified but not evaluating the content would remove the $slot.default property access, and that would be a breaking change

@posva posva closed this Apr 15, 2019

@FranckFreiburger

This comment has been minimized.

Copy link
Author

FranckFreiburger commented Apr 15, 2019

Thank you for this clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.