CustomElement.svelte
<svelte:options tag="custom-element" />
<script>
import { onMount, onDestroy } from "svelte";
onMount(() => {
window.addEventListener("scroll", funcRef);
});
onDestroy(() => {
window.removeEventListener("scroll", funcRef);
});
const funcRef = (event) => {
doWhatever();
}
</script>
Actually, the event handler should be removed when the custom element gets removed from the document, but it won't. What am I missing?