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

v-if cannot access slot scope with new slot syntax #9862

Closed
econic opened this Issue Apr 11, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@econic
Copy link

econic commented Apr 11, 2019

Version

2.6.10

Reproduction link

https://codesandbox.io/s/7j9o6o4310?fontsize=14

Steps to reproduce

Use a component that defines a scoped slot like this

<MyComponent>
  <template v-if="scope.foo" #myslotname="scope">...</template>
</MyComponent>

What is expected?

The template should evaluate the slot directive first, v-if second. Just as it is done with v-for first, v-if second.

What is actually happening?

The template evaluates the v-if first, resulting in an error (unknown component property)


This functionality was present in the deprecated slot syntax, i stumbled upon it while refactoring to the new one.
It is possible to workaround this with a nested template with the respected v-if

I'm using latest Vue, TypeScript, SFC

@posva

This comment has been minimized.

Copy link
Member

posva commented Apr 11, 2019

I couldn't find the duplicate of this but this is now expected behaviour because the v-if has higher priority. As you said, using a nested template is the way to go

@posva posva closed this Apr 11, 2019

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.