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

A deliberately empty slot-scope attribute will not be rendered as a scoped slot #8912

Open
decademoon opened this issue Oct 9, 2018 · 10 comments

Comments

@decademoon
Copy link
Contributor

decademoon commented Oct 9, 2018

Version

2.5.17

Reproduction link

https://jsfiddle.net/decademoon/50wL7mdz/759740/

Steps to reproduce

<foo>
  <bar slot-scope/>
</foo>

What is expected?

<bar slot-scope> should be a scoped slot.

What is actually happening?

<bar slot-scope> is rendered as a child as if slot-scope were not present.


As a workaround, I've been using a dummy variable to force it to be a scoped slot:

<bar slot-scope="scope"/>

@posva
Copy link
Member

posva commented Oct 9, 2018

I'm pretty sure we talked about this in another issue but couldn't find it 🤔

@basselAhmed
Copy link

Hi @decademoon I'd like to pick this up, can you check this sandbox and tell me if it's the correct behavior for your use case?
https://codesandbox.io/s/4q15jlq12w

@smolinari
Copy link

For my curiosity, what is the use case for doing this?

Scott

@decademoon
Copy link
Contributor Author

@basselAhmed Yes that appears to be correct.

@smolinari One example is the Foo component may want to render the slot multiple times, in which case the slot needs to be scoped in order for it to be a function which will return a different vnode instance each time it is called.

@smolinari
Copy link

Um, can you expand that with a real world example, maybe even with code? I'm still not understanding. Sorry. And thanks for being patient with me.

Scott

@Justineo
Copy link
Member

@smolinari See #8496. Currently Vue doesn't allow a slot to be rendered more than once, the workaround for now is using a scoped slot without meaningful scope arguments.

@basselAhmed
Copy link

Thanks, I'll create a PR for this shortly.

@smolinari
Copy link

Thanks. With the breadcrumb separator use case, this issue now makes sense.

Scott

@WORMSS
Copy link
Contributor

WORMSS commented Nov 20, 2019

@smolinari See #8496. Currently Vue doesn't allow a slot to be rendered more than once, the workaround for now is using a scoped slot without meaningful scope arguments.

Is that true? Because if you add two default slots, it's rendered twice. (Which I am trying to actually not happen)

@jacekkarczmarczyk
Copy link

The comment was added before the fix was released

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

No branches or pull requests

7 participants