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
When i use a class directive that contain reactive values, the class set by the action is removed when the value updates.
I'm not sure if this is actually a bug or the expected behavior, since one could argue that the source of truth for the classes should be handled only by the component.
However i feel like actions kind of encourage classes to be added by them.
The problem only occurs for dynamic values inside class
class={"Button" + (small ? "small": "large")}
using a class:small directive for example does not remove the action class.
Is it possible to parse out any static value and continue to set them via $.set_class
while dynamic values get treated differently? At least for static analyzable values like in the example above the compiler could probably generate something like this?
const small = $.get(small);
$.toggle_class(button_1, "small", small);
$.toggle_class(button_1, "large", !small);
Describe the bug
I have an action that sets a class.
When i use a class directive that contain reactive values, the class set by the action is removed when the value updates.
I'm not sure if this is actually a bug or the expected behavior, since one could argue that the source of truth for the classes should be handled only by the component.
However i feel like actions kind of encourage classes to be added by them.
The problem only occurs for dynamic values inside
class
using a class:small directive for example does not remove the action class.
Is it possible to parse out any static value and continue to set them via
$.set_class
while dynamic values get treated differently? At least for static analyzable values like in the example above the compiler could probably generate something like this?
Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE5WOQUvEMBCF_8o4eGix7Hqu7cqqR4-CB-MhptMlbJqUzlSQkv8uSdC9CZ4m8-blfW_D0TpibN829HoibPE4z9igfM1p4U9yQtggh3UxSenYLHaWg_JKHAmYsHqBHq5ZtFB1W98pn27j6o3Y4EHnUfkwUA1bOilJy844zfxsWXZ6GCqFx2x8TKrCOhljiUoYnrRzF8yoHVNCdftLH999rCLBw8rUFixkSJt_91sesWj9pvAh2xVGCN44a879VtXQH0rNH-RVfigf4-ElnE6O4DUsZ-72hfYn-UIBhXADVQm9B4UlFVtQ6PRyIoX1f3s8BWLwQXKh3z7Y4BQGO1oasJVlpfgevwGNOoQQ6AEAAA==
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: