2022-02-23 13:52:06 +00:00
|
|
|
/**
|
|
|
|
* Creates an HTML Element from a given string. Only use this when using
|
2023-06-25 10:00:43 +00:00
|
|
|
* Preact isn't practical.
|
2022-02-23 13:52:06 +00:00
|
|
|
*/
|
|
|
|
export function createElementFromString<T extends Element>(input: string): T {
|
2023-06-23 10:52:03 +00:00
|
|
|
const template = document.createElement("template");
|
2022-02-23 13:52:06 +00:00
|
|
|
template.innerHTML = input.trim();
|
|
|
|
return template.content.firstElementChild as T;
|
|
|
|
}
|