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

Regular slot and scoped slot with same name shouldn't be allowed #10149

Open
lee88688 opened this issue Jun 13, 2019 · 8 comments
Open

Regular slot and scoped slot with same name shouldn't be allowed #10149

lee88688 opened this issue Jun 13, 2019 · 8 comments
Labels

Comments

@lee88688
Copy link

lee88688 commented Jun 13, 2019

Version

2.6.10

Reproduction link

https://codepen.io/lee88688/pen/jjPpBm?editors=1010

Steps to reproduce

as seen in codepen, "hello" component have only one slot. but rendered 2 div tag at last. I have a look at Vue's code renderSlot which seems renderSlot function would treat the normal slot as scoped slot. why it would be like this?

the following code is render function of hello component which is compiled by Vue.compile. _t is renderSlot function. when normal slot and scoped slot in same component the problem above will be present.

(function anonymous() {
    with (this) {
        return _c('div', [_t("default"), _v(" "), _t("default", null, {
            "x": x
        })], 2)
    }
}
)

What is expected?

render just one slot.

What is actually happening?

render one slot twice.

@posva
Copy link
Member

posva commented Jun 13, 2019

You cannot name a scoped slot and a regular slot the same way
Maybe we could issue a warning for this

@posva posva added contribution welcome feature request warnings related to development warnings labels Jun 13, 2019
@posva posva changed the title one scoped slot would render twice in some case Regular slot and scoped slot with same name shouldn't be allowed Jun 13, 2019
@lee88688
Copy link
Author

I really recommend adding this warning in docs. as I read the docs, I don't realize this may be a problem for me.

@underfin
Copy link
Member

I think it`s correct.In a way, a regular slot is a socped slot,only the context is underfined, the same name solt is can used by twice times. Maybe the user want to do like this.

@posva
Copy link
Member

posva commented Jun 20, 2019 via email

@kerm1it
Copy link

kerm1it commented Jun 29, 2019

@posva I will work it.

@DrKlonk
Copy link

DrKlonk commented Jul 9, 2021

We tried to solve this issue with a small group, but we were unable to reproduce it in Vue 3. In the docs for Vue 3 this seems to be using a different approach. We are unsure if this issue is still relevant for Vue 3.

@kerm1it Does your commit fix the issue? If yes, are you planning on turning this into a PR?

Could you please let us know if this is still an issue? If so, we'd like to help find a solution.

If not, it might be worth it to close this issue.

@kerm1it
Copy link

kerm1it commented Jul 9, 2021

@kerm1it
Copy link

kerm1it commented Jul 9, 2021

#10217

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

No branches or pull requests

5 participants