Skip to content

Commit d017771

Browse files
authored
fix : Rapidly toggling element with out: transition causes incorrect node removal (#13884)
* set onfinish to null to fix a rare bug * replace null by noop
1 parent 42ccdc1 commit d017771

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/svelte/src/internal/client/dom/elements/transitions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ function animate(element, options, counterpart, t2, on_finish) {
427427
animation.cancel();
428428
// This prevents memory leaks in Chromium
429429
animation.effect = null;
430+
// This prevents onfinish to be launched after cancel(),
431+
// which can happen in some rare cases
432+
// see https://github.com/sveltejs/svelte/issues/13681
433+
animation.onfinish = noop;
430434
}
431435
},
432436
deactivate: () => {

0 commit comments

Comments
 (0)