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

Unexpected behavior with props on named slots #7245

Closed
gtm-nayan opened this issue Feb 11, 2022 · 1 comment
Closed

Unexpected behavior with props on named slots #7245

gtm-nayan opened this issue Feb 11, 2022 · 1 comment

Comments

@gtm-nayan
Copy link
Contributor

Describe the bug

From the docs (emphasis mine)

Named slots can also expose values. The let: directive goes on the element with the slot attribute.

However it seems that those props can also be exposed through a let: on the <Component>. Not entirely sure whether this is an actual bug or just lacking better documentation.

Reproduction

https://svelte.dev/repl/f3fa64f34cc740deb6b7ed7dca0bf657?version=3.46.4

Logs

No response

System Info

Chromium 98.0.4758.87

Severity

annoyance

@gtm-nayan gtm-nayan changed the title Unexpected behavior with named slots Unexpected behavior with props on named slots Feb 11, 2022
@rudrakpatra
Copy link

rudrakpatra commented Feb 14, 2022

I have run into the same problem.
I modified your example into this.

currently (version=3.46.4)
if you use let:style on the component ('style' is prop name)
the value of the the style prop changes based on the slot which is currently being rendered
in the linked example
the first two slots render with their own prop values
for the last slot style is undefined as it is not present in the slot.

I don't think of this as a bug anymore.
In cases where all the slots have the same prop names it's better to use this approach.( write let: once)
I think an explanation for this behaviour should be present in the official example for slot props.

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

No branches or pull requests

3 participants