diff --git a/.changeset/sweet-sheep-sell.md b/.changeset/sweet-sheep-sell.md new file mode 100644 index 000000000000..986a60478f60 --- /dev/null +++ b/.changeset/sweet-sheep-sell.md @@ -0,0 +1,5 @@ +--- +'@astrojs/svelte': patch +--- + +Fix potential memory leak when component is unmounted diff --git a/packages/integrations/svelte/client.js b/packages/integrations/svelte/client.js index 73cc305c147e..9e3df401915c 100644 --- a/packages/integrations/svelte/client.js +++ b/packages/integrations/svelte/client.js @@ -3,9 +3,9 @@ const noop = () => {}; let originalConsoleWarning; let consoleFilterRefs = 0; -export default (target) => { +export default (element) => { return (Component, props, slotted, { client }) => { - if (!target.hasAttribute('ssr')) return; + if (!element.hasAttribute('ssr')) return; const slots = {}; for (const [key, value] of Object.entries(slotted)) { slots[key] = createSlotDefinition(key, value); @@ -15,7 +15,7 @@ export default (target) => { if (import.meta.env.DEV) useConsoleFilter(); const component = new Component({ - target, + target: element, props: { ...props, $$slots: slots,