You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the Child component is the only element in the markup that uses the class, the styles are marked as unused. I suppose therefore they will just become removed during compilation, right?
If a second element using the styles is placed in the markup, svelte correctly generates the svelte- hash class for the current scope, and also correctly applies the styles to the second element. The first element however does not get the scoped svelte class applied.
Expected behavior
If I pass down the classname to a child component, I expect the styles to not being marked as unused and svelte to apply the scoped hash class to the child component.
The text was updated successfully, but these errors were encountered:
This feature is working as intended, and this issue is basically a duplicate of #2870/#2888, which is not how we want to handle styling child components.
A prop called class on a component shouldn't be treated specially. You can manually declare a prop called class and use it however you want within the component, and/or you can use :global() around parts of selectors to refer to elements in other components (including child components).
You may also be interested in sveltejs/rfcs#13 which is a proposal for how to style child components using an API explicitly defined by the child.
Describe the bug
In https://svelte.dev/docs#script there is a part on how to expose reserved keywords like
class
to parent components.I tried to include this in my app, but the optimizations / scoping of styles prevent that with the current version 3.17.1
To Reproduce
https://svelte.dev/repl/59207aa8c9284598a44489414267796c?version=3.17.1
Actual behaviour
Expected behavior
If I pass down the classname to a child component, I expect the styles to not being marked as unused and svelte to apply the scoped hash class to the child component.
The text was updated successfully, but these errors were encountered: