Closed
Description
Describe the bug
Reading sub-component's prop in eventListener causes sub-component's $effect getting triggered.
<script lang='ts'>
$host().addEventListener('change', () => {
$host().querySelectorAll('my-custom-element').forEach((el: any) => {
// Simple read causes $effect to trigger
el.value;
});
})
</script>
See Reproduction for detail.
Reproduction
https://github.com/satouriko/svelte-effect-bug
Typing in the first input, it triggers the $effect of itself, that's good.
While then type in the second, it triggers the $effect of both itself and the first one.
Then type in the third one, it triggers all the three $effects.
That's weird. Why reading properties cause $effect?
2024-08-09.14.16.59.mov
Logs
No response
System Info
Svelte 5.0.0-next.210
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
Severity
annoyance