fix(svelte): unmount islands properly on navigation (#8448)
This commit is contained in:
parent
f3f62a5a20
commit
3f49aa97ab
2 changed files with 8 additions and 3 deletions
5
.changeset/sweet-sheep-sell.md
Normal file
5
.changeset/sweet-sheep-sell.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/svelte': patch
|
||||
---
|
||||
|
||||
Fix potential memory leak when component is unmounted
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue