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
As described by this comment it is possible to write expressions like the following for class bindings as false and nil values are discarded:
<divclass={["my-class", @foo? and "my-class--modifier"]}>
...
</div>
This is great because it allows developers to easily implement additional css classes if a condition is true and otherwise it will just be discarded. However the same behaviour doesn't work for the style attribute:
<divstyle={["--my-target: 100", "--my-value: 50", @label and "--label: #{@label}"]}>
...
</div>
I believe the problem is that this would be backwards incompatible. IIRC, when we added the changes to class, we had to launch a major version, and I am not sure this is an important enough feature to justify a new major release of this library. Perhaps we leave this open and revisit by the time of a new major version?
As described by this comment it is possible to write expressions like the following for class bindings as
false
andnil
values are discarded:This is great because it allows developers to easily implement additional css classes if a condition is true and otherwise it will just be discarded. However the same behaviour doesn't work for the
style
attribute:This raises the argument error (from here)
Given the flexibility that CSS custom properties offers I think it would be a great addition to the syntax.
Current workaround to this issue would be to write it as the following (which doesn't read as good and looks more complex than needed to be):
Is there any security concern in play here or would this be an easy addition?
Thanks
The text was updated successfully, but these errors were encountered: