fix(svelte): unmount islands properly on navigation (#8448)

This commit is contained in:
Nate Moore 2023-09-07 09:49:59 -05:00 committed by GitHub
parent f3f62a5a20
commit 3f49aa97ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/svelte': patch
---
Fix potential memory leak when component is unmounted

View file

@ -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,