From d2eab5a3d34b9ef2c76fd03dc777e0b2c495cdc1 Mon Sep 17 00:00:00 2001 From: adiguba Date: Thu, 24 Oct 2024 21:24:13 +0200 Subject: [PATCH 1/2] set onfinish to null to fix a rare bug --- .../svelte/src/internal/client/dom/elements/transitions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index c8c297a394ac..caaa7d102edd 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -427,6 +427,10 @@ function animate(element, options, counterpart, t2, on_finish) { animation.cancel(); // This prevents memory leaks in Chromium animation.effect = null; + // This prevents onfinish to be launched after cancel(), + // which can happen in some rare cases + // see https://github.com/sveltejs/svelte/issues/13681 + animation.onfinish = null; } }, deactivate: () => { From 10af1186a82887eaf4e47ab8c7383dd27630e789 Mon Sep 17 00:00:00 2001 From: adiguba Date: Thu, 24 Oct 2024 21:36:23 +0200 Subject: [PATCH 2/2] replace null by noop --- packages/svelte/src/internal/client/dom/elements/transitions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index caaa7d102edd..dee029e88f85 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -430,7 +430,7 @@ function animate(element, options, counterpart, t2, on_finish) { // This prevents onfinish to be launched after cancel(), // which can happen in some rare cases // see https://github.com/sveltejs/svelte/issues/13681 - animation.onfinish = null; + animation.onfinish = noop; } }, deactivate: () => {