refactoring

This commit is contained in:
Pieter Vander Vennet 2023-03-28 05:13:48 +02:00
parent b94a8f5745
commit 5d0fe31c41
114 changed files with 2412 additions and 2958 deletions

View file

@ -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} />