forked from MapComplete/MapComplete
refactoring
This commit is contained in:
parent
b94a8f5745
commit
5d0fe31c41
114 changed files with 2412 additions and 2958 deletions
|
@ -1,18 +1,23 @@
|
|||
<script lang="ts">
|
||||
import BaseUIElement from "../BaseUIElement.js"
|
||||
import { onMount } from "svelte"
|
||||
|
||||
export let construct: BaseUIElement | (() => BaseUIElement)
|
||||
let elem: HTMLElement
|
||||
import BaseUIElement from "../BaseUIElement.js";
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
|
||||
export let construct: BaseUIElement | (() => BaseUIElement);
|
||||
let elem: HTMLElement;
|
||||
let html: HTMLElement;
|
||||
onMount(() => {
|
||||
let html =
|
||||
typeof construct === "function"
|
||||
? construct().ConstructElement()
|
||||
: construct.ConstructElement()
|
||||
const uiElem = typeof construct === "function"
|
||||
? construct() : construct;
|
||||
html =uiElem?.ConstructElement();
|
||||
if (html !== undefined) {
|
||||
elem.replaceWith(html);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
html?.remove();
|
||||
});
|
||||
|
||||
elem.replaceWith(html)
|
||||
})
|
||||
</script>
|
||||
|
||||
<span bind:this={elem} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue