-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Svelte 5: this type of directive is not valid on components #12229
Comments
Duplicate of #2870 + #5236. And it's never worked, so it's a feature request but not a bug. This topic has been raised multiple times, but no really good solution has been proposed. You still get more flexibility with <div class="wrapper">
<MyComponent class={isRTL ? "rtl" : ""}>
This will work
</MyComponent>
</div>
...
<style>
.wrapper :global(.rtl) {
direction: rtl;
}
</style> |
Agreed, it's a feature request, not a bug Note that I am not saying there is no ways around it. What I am saying is that there must be a more intuitive way. Here is my analysis, I find that there is nothing Svelte in the current behavior.
consider the code below:
The proposed syntax:
All we are doing with this I am happy to see other tickets will people having the same opinion. Last point, it can be done with other frameworks.. why not in Svelte?! |
Here is team conclusion on it. Also a good point, plus its continuetion. 3rd-party solution: preprocessor (though seems kinda dead). There are a whole bunch of questions to whatever proposed solution:
|
I will need to read each of these pointers, thank you. Looks like I am not the only one... The points however make little sense to me as they all focus on the component implementation, where the proposed solution is used to simplify the concatenation of values when the component is called. Maybe I am missing something myself, please enlighten me. |
Adding the It would indicate that the |
I am not saying by now, I've seen many way around, people are suggesting to pass the parameters down and handle the css class from within the component. this is great if it's your code... not if the components are purchased and closed source. anyway, for me it's a big miss in svelte 5 as it stands today. actually if anyone can point to a way to implement it via a plugin, I'll be happy to use it |
It's not, because this only makes any sense for You could use a utility like |
interesting utility indeed, thank you |
Describe the bug
The code below will bark on class: "this type of directive is not valid on components"
This is very frustrating. Not only does it fail to compile, but manually creating the class string won't be detected by Svelte, and the .rtl CSS class will be marked as unused.
Reproduction
REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: