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">
import BaseUIElement from "../BaseUIElement.js";
import { onMount } from "svelte";
import BaseUIElement from "../BaseUIElement.js"
import { onMount } from "svelte"
export let construct: BaseUIElement | (() => BaseUIElement)
let elem: HTMLElement
export let construct: BaseUIElement | (() => BaseUIElement);
let elem: HTMLElement;
onMount(() => {
let html: HTMLElement
if (typeof construct === "function") {
html = construct().ConstructElement();
} else {
html = construct.ConstructElement();
}
let html =
typeof construct === "function"
? construct().ConstructElement()
: construct.ConstructElement()
elem.replaceWith(html)
});
})
</script>
<span bind:this={elem}></span>
<span bind:this={elem} />