From dcc1e895abbad1311719803363c933541c0ad984 Mon Sep 17 00:00:00 2001 From: Hermit <70563349+hermit99@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:59:01 +1000 Subject: [PATCH] Fix-component-undefined-svelte-v5 (#12102) * - fix: 'component is not defined' error when unmount svelte 5 component * added changeset * Moving unmount listener to where the component is defined. * Update .changeset/eighty-ligers-punch.md Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> --------- Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> --- .changeset/eighty-ligers-punch.md | 5 +++++ packages/integrations/svelte/client-v5.js | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/eighty-ligers-punch.md diff --git a/.changeset/eighty-ligers-punch.md b/.changeset/eighty-ligers-punch.md new file mode 100644 index 0000000000..ee7acbec3b --- /dev/null +++ b/.changeset/eighty-ligers-punch.md @@ -0,0 +1,5 @@ +--- +'@astrojs/svelte': patch +--- + +Fixes an Reference Error that occurred during client transitions diff --git a/packages/integrations/svelte/client-v5.js b/packages/integrations/svelte/client-v5.js index 78bab3ea34..7a046b5bfd 100644 --- a/packages/integrations/svelte/client-v5.js +++ b/packages/integrations/svelte/client-v5.js @@ -39,8 +39,7 @@ export default (element) => { }, }); existingApplications.set(element, component); + element.addEventListener('astro:unmount', () => unmount(component), { once: true }); } - - element.addEventListener('astro:unmount', () => unmount(component), { once: true }); }; };