You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/custom-elements/samples/ondestroy/main.svelte

23 lines
357 B

<svelte:options customElement="my-app" />
<script>
import { onMount, onDestroy } from "svelte";
let el;
let parentEl;
onMount(() => {
parentEl = el.parentNode.host.parentElement;
return () => {
parentEl.dataset.onMountDestroyed = true;
};
});
onDestroy(() => {
parentEl.dataset.destroyed = true;
});
</script>
<div bind:this={el} />