mapcomplete/UI/Base/ToSvelte.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
511 B
Svelte
Raw Normal View History

<script lang="ts">
import BaseUIElement from "../BaseUIElement.js"
import { onDestroy, onMount } from "svelte"
export let construct: BaseUIElement | (() => BaseUIElement)
let elem: HTMLElement
let html: HTMLElement
onMount(() => {
const uiElem = typeof construct === "function" ? construct() : construct
html = uiElem?.ConstructElement()
2023-03-28 05:13:48 +02:00
if (html !== undefined) {
elem.replaceWith(html)
2023-03-28 05:13:48 +02:00
}
})
2023-03-28 05:13:48 +02:00
onDestroy(() => {
html?.remove()
})
</script>
2023-02-03 14:59:08 +01:00
<span bind:this={elem} />