I'm using some external code that returns an HTML element, and it'd be nice to embed it without having to manage the loading and everything via JavaScript (i.e. appendChild/removeChild). Right now I'm using {@html element.outerHTML}, but this seems inelegant to make the round trip to an HTML string:
<script>
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function someCall() {
await sleep(1000);
const p = document.createElement("p");
p.innerText = "hello!";
console.log(p);
return p;
}
let data = someCall();
</script>
<div>
{#await data}
<p>Loading data...</p>
{:then result}
{@html result.outerHTML}
{/await}
</div>
What I'm looking for might be something like
<div>
{#await data}
<p>Loading data...</p>
{:then result}
{result}
{/await}
</div>
but this doesn't work (since it string-ifies the element).