Skip to content

Commit

Permalink
fix(svelte): unmount islands properly on navigation (#8448)
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Sep 7, 2023
1 parent f3f62a5 commit 3f49aa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-sheep-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/svelte': patch
---

Fix potential memory leak when component is unmounted
6 changes: 3 additions & 3 deletions packages/integrations/svelte/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -15,7 +15,7 @@ export default (target) => {
if (import.meta.env.DEV) useConsoleFilter();

const component = new Component({
target,
target: element,
props: {
...props,
$$slots: slots,
Expand Down

0 comments on commit 3f49aa9

Please sign in to comment.