From 24683c46e626a5f7537f4b21e6f31d41f4e416e9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 14 Dec 2024 08:40:54 -0500 Subject: [PATCH] remove from map immediately --- packages/svelte/src/internal/client/render.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index f1203857f947..f4b7944c14c5 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -252,7 +252,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro } root_event_handles.delete(event_handle); - mounted_components.delete(component); + if (anchor_node !== anchor) { anchor_node.parentNode?.removeChild(anchor_node); } @@ -293,6 +293,7 @@ export function unmount(component, options) { const fn = mounted_components.get(component); if (fn) { + mounted_components.delete(component); return fn(options); }