forked from MapComplete/MapComplete
Cleanup ToSvelte component
This commit is contained in:
parent
cd735c1571
commit
b1b4e6acba
1 changed files with 13 additions and 12 deletions
|
@ -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} />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue