sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.71k stars 4.23k forks source link

Doc mismatch with `$effect.active()` behavior in optimized static blocks #13903

Open Conduitry opened 1 week ago

Conduitry commented 1 week ago

Describe the bug

In the example code in the documentation, $effect.active() in the template returns false, not true as advertised. This is seemingly because the render effect is optimized away because that node has no dynamic content.

I don't know which behavior is more correct. Probably the current one? The current behavior is a bit more confusing to document, though.

Reproduction

https://svelte.dev/docs/svelte/$effect#$effect.tracking

Logs

No response

System Info

n/a

Severity

annoyance

Conduitry commented 1 week ago

Per Rich, maybe we want to change the behavior of $effect.active() here, rather than trying to document the current behavior. The only cases where this would matter would be toy ones where the user is only calling $effect.active() in a given node in the template.