-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
class:
/style:
directives can be overridden by class
/style
attributes
#13270
Comments
Oh yeah it's my fault...I thought reverting my initial fix and using deriveds was enough but dummily didn't test for this. But you are right, the two should be in the same template effect. However I was confident it was not a problem because I remember a test failing for this when I made my initial fix and it was not failing with the derived. |
Uh actually: the problem was there before because the template effects were still separate (testing this on a version before the PR still has the problem)...but I should've fixed it in my pr probably 😁 |
Working on this locally. Noticed another issue, possibly as a result of #13171 — we create an unnecessary derived when there's only a single call expression in the set of class/style directives/attributes — this... const class_directive = $.derived(lol);
$.template_effect(() => $.toggle_class(button, "banana", $.get(class_directive))); ...should be this: $.template_effect(() => $.toggle_class(button, "banana", lol())); |
But when you create the class directive you can't know if while visiting the nodes we will add something else to the |
@Conduitry I assumed you reopened this because it's still an issue? |
yep, see #13338 |
Describe the bug
I'm not sure if this is related to #13171 or not, but
class:
/style:
directives can be overridden byclass
/style
attributes, which they shouldn't - the directives always take precedent. It happens if theclass:/style:
directive doesn't update/rerun while the correspondingclass/style
attribute does update.The solution is probably to ensure that the directives are always in the same template effect as the corresponding attributes so that they rerun. Alternatively there's some hidden property on the DOM elements that tells them what other classes should be on there at that point.
Reproduction
https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACl2P4WrDMAyEX0WIjaQ0kLGfmeOy51jGcB1lNXGdYMspw_jdhxfGRn_qdLr7lHAylgJ2bwmduhJ2-Lqu2CB_rWUIG1kmbDAs0euiiKC9WVkObmBLDJuykaCHh8CKqX46vAyu7KboNJvFwaj8XB9S0Qb2xNE7YB-p-DjfmT-JP7RVIdxf7DWP8AwnqG4Xw1RBB9XZKj1Xv1Gi_YNzYjQb_GR1BaFPO0jetT79q8pStKPZ5ODEOTIvDhanrdFzn-pDL_fy4zHLcDOsL6LdXRIbvC6jmQyN2JWf8nv-BkMMS5xSAQAA
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: