Skip to content

Commit

Permalink
Moving unmount listener to where the component is defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
hermit99 committed Oct 5, 2024
1 parent 4a219bc commit 88d8d88
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/integrations/svelte/client-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ export default (element) => {
}

const bootstrap = client !== 'only' ? hydrate : mount;
let component = null;
if (existingApplications.has(element)) {
existingApplications.get(element).$set({
...props,
children,
$$slots,
});
} else {
component = bootstrap(Component, {
const component = bootstrap(Component, {
target: element,
props: {
...props,
Expand All @@ -40,8 +39,7 @@ export default (element) => {
},
});
existingApplications.set(element, component);
element.addEventListener('astro:unmount', () => unmount(component), { once: true });
}

element.addEventListener('astro:unmount', () => component && unmount(component), { once: true });
};
};

0 comments on commit 88d8d88

Please sign in to comment.