-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the bug
This is a duplicate of #3290 which was closed, though the issue still exists.
beforeUpdate
is called twice when using bind:this
.
Logs
No errors were shown in logs
To Reproduce
https://svelte.dev/repl/3381c9b40dc8441a8e4ebfa48fd8c178 (credit to beomy)
<script>
import { beforeUpdate, afterUpdate } from 'svelte';
let p;
beforeUpdate(() => {
console.log('beforeUpdate');
})
afterUpdate(() => {
console.log('afterUpdate');
})
</script>
<p bind:this={p}></p>
Open the console to view the behavior. It produces:
beforeUpdate
afterUpdate
beforeUpdate
Expected behavior
beforeUpdate should only be called once during a single update cycle.
beforeUpdate
afterUpdate
Severity
Severity is High, as the the cycle should always end with an afterUpdate
and not a repeated beforeUpdate
.
Other
#3308, was made to potentially fix this issue but appears that it was never merged. The reason given was that it was fixed in 3.18.2, but the issue still exists. https://svelte.dev/repl/3381c9b40dc8441a8e4ebfa48fd8c178?version=3.18.2.