Skip to content

Commit

Permalink
Fix destroy method
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Oct 1, 2024
1 parent ac8cc1e commit 7b5889a
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/lib/components/layouts/Portal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { beforeNavigate } from "$app/navigation";
export let target: HTMLElement | null | undefined = globalThis.document?.body;
Expand All @@ -15,19 +14,10 @@
}
});
beforeNavigate(() => {
if (ref?.parentNode) {
ref.parentNode?.removeChild(ref);
}
});
// this block is almost needless/useless (if not totally) as, on destroy, the ref will no longer exist/be in the DOM anyways
onDestroy(() => {
setTimeout(() => {
if (ref?.parentNode) {
ref.parentNode?.removeChild(ref);
}
});
if (target) {
target.removeChild(ref);
}
});
</script>

Expand Down

0 comments on commit 7b5889a

Please sign in to comment.