-
-
Notifications
You must be signed in to change notification settings - Fork 952
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
When using a "computed key" in classList, a following class
declaration overwrites the classes set by classList
#2050
Comments
class
declaration overwrites the classList
set classclass
declaration overwrites the classes set by classList
Technically as far is it concerned class is reactive here because you are using props.class syntax. It can't know that it isn't. Reactive class means there is always potential for it to overwrite. We can't do inline optimizations on classList with computed keys currently. I suppose the compiler could be more optimized. But this is generally the problem with reactive class + classList and why there is intention to do something about classList in the future. |
Hmm, I thought the rules was that one can use classList and class together as long as only one is reactive.
But I didn't know about this :( Why is it not possible? I need computed keys to get dashes in the class lol. If I was solid I'd tackle the problem by splitting Edit:
I'm obviously stupid, I can just do |
To be fair computed property compilation is probably possible if the computed property itself isn't dynamic (a signal or member expression). Also a literal could be eliminated too. These are all optimization edge cases. I just bailed out the optimization sooner because of sake of time and some complexity I hit. That being said this behavior due to the way |
That's totally fair. Thanks for the information! But I still wonder about your reasoning regarding why not split class into classList in the JSX transformation output for now to fix all the bugs, at the expense of some performance? |
As far as I know, you can put multiple classes inside ONE element of <div classList={{ [`${MY_CLASS_1} ${MY_CLASS_2}`]: true, [MY_CLASS_3]: condition }} /> The compiler would even be able to choose not to use this approach depending on whether both |
Describe the bug
classList
doesn't work when used together withclass
, even whenclassList
is not reactive, if the object looks like this{ ["test"]: true }
instead of{ test: true }
Your Example Website or App
https://playground.solidjs.com/anonymous/a669dae1-46b2-4366-9df0-91d6527908c6
Steps to Reproduce the Bug or Issue
class-2
being logged to the consoleExpected behavior
class-1
being logged to the consoleScreenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: