Cleanup ToSvelte component

This commit is contained in:
wjtje 2023-02-03 14:59:08 +01:00 committed by Pieter Vander Vennet
parent cd735c1571
commit b1b4e6acba

View file

@ -1,17 +1,18 @@
<script lang="ts"> <script lang="ts">
import BaseUIElement from "../BaseUIElement.js"; import BaseUIElement from "../BaseUIElement.js"
import { onMount } from "svelte"; import { onMount } from "svelte"
export let construct: BaseUIElement | (() => BaseUIElement)
let elem: HTMLElement
export let construct: BaseUIElement | (() => BaseUIElement);
let elem: HTMLElement;
onMount(() => { onMount(() => {
let html: HTMLElement let html =
if (typeof construct === "function") { typeof construct === "function"
html = construct().ConstructElement(); ? construct().ConstructElement()
} else { : construct.ConstructElement()
html = construct.ConstructElement();
}
elem.replaceWith(html) elem.replaceWith(html)
}); })
</script> </script>
<span bind:this={elem}></span>
<span bind:this={elem} />