summaryrefslogtreecommitdiff
path: root/packages/integrations/solid/src
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2023-08-29 09:30:11 -0500
committerGravatar GitHub <noreply@github.com> 2023-08-29 09:30:11 -0500
commit1f58a7a1bea6888868b689dac94801d554319b02 (patch)
treed211fa64f18e32ca0798e1ca93b96c2477eea322 /packages/integrations/solid/src
parent9e021a91c57d10809f588dd47968fc0e7f8b4d5c (diff)
downloadastro-1f58a7a1bea6888868b689dac94801d554319b02.tar.gz
astro-1f58a7a1bea6888868b689dac94801d554319b02.tar.zst
astro-1f58a7a1bea6888868b689dac94801d554319b02.zip
Unmount framework components when islands are destroyed (#8264)
* fix(view-transitions): update persistence logic for improved unmount behavior * feat(astro): add `astro:unmount` event * feat(vue): automatically unmount islands * feat(react): automatically unmount islands * feat(react): automatically unmount islands * feat(solid): automatically dispose of islands * feat(svelte): automatically destroy of islands * feat(svelte): automatically destroy of islands * feat(solid): automatically dispose of islands * feat(preact): automatically unmount islands * chore: update changeset * fix: rebase issue * chore: add clarifying comment * chore: remove duplicate changeset * chore: add changeset
Diffstat (limited to 'packages/integrations/solid/src')
-rw-r--r--packages/integrations/solid/src/client.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/integrations/solid/src/client.ts b/packages/integrations/solid/src/client.ts
index 730db0f51..66b3767ea 100644
--- a/packages/integrations/solid/src/client.ts
+++ b/packages/integrations/solid/src/client.ts
@@ -9,7 +9,7 @@ export default (element: HTMLElement) =>
}
if (!element.hasAttribute('ssr')) return;
- const fn = client === 'only' ? render : hydrate;
+ const boostrap = client === 'only' ? render : hydrate;
let _slots: Record<string, any> = {};
if (Object.keys(slotted).length > 0) {
@@ -30,7 +30,7 @@ export default (element: HTMLElement) =>
const { default: children, ...slots } = _slots;
const renderId = element.dataset.solidRenderId;
- fn(
+ const dispose = boostrap(
() =>
createComponent(Component, {
...props,
@@ -42,4 +42,6 @@ export default (element: HTMLElement) =>
renderId,
}
);
+
+ element.addEventListener('astro:unmount', () => dispose(), { once: true })
};