diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index 5506737e31..4d54e4e887 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -234,6 +234,12 @@ export function branch(fn) { * @returns {void} */ export function destroy_effect(effect) { + var dom = effect.dom; + + if (dom !== null) { + remove(dom); + } + destroy_effect_children(effect); remove_reactions(effect, 0); set_signal_status(effect, DESTROYED); @@ -246,10 +252,6 @@ export function destroy_effect(effect) { effect.teardown?.call(null); - if (effect.dom !== null) { - remove(effect.dom); - } - var parent = effect.parent; // If the parent doesn't have any children, then skip this work altogether