We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The class:directive can produce multiple mutations on DOM.
class:directive
Example with this code :
<script> let { className, bar, baz } = $props(); </script> <div class={className} class:bar class:baz>...</div>
Currently we got the following code :
$.template_effect(() => { $.set_class(div, $.clsx($$props.className)); $.toggle_class(div, 'bar', $$props.bar); $.toggle_class(div, 'baz', $$props.baz); });
With the props { className: "foo", bar: true, baz: true } :
{ className: "foo", bar: true, baz: true }
<div class="foo bar baz">...</div>
set_class()
"foo"
toggle_class('bar')
bar
"foo bar"
toggle_class('baz')
baz
"foo bar bar"
It would be nice to define the class once (except for the reactivity after that of course)
Need to watch the DOM, or add a MutationObserver on the page...
-
annoyance
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
The
class:directive
can produce multiple mutations on DOM.Example with this code :
Currently we got the following code :
With the props
{ className: "foo", bar: true, baz: true }
:<div class="foo bar baz">...</div>
✅set_class()
will set the class to"foo"
toggle_class('bar')
will add the classbar
, so he class will be"foo bar"
toggle_class('baz')
will add the classbaz
, so he class will be"foo bar bar"
It would be nice to define the class once (except for the reactivity after that of course)
Reproduction
Need to watch the DOM, or add a MutationObserver on the page...
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: