1
Fork 0
tildes-reextended/source/utilities/elements.ts

10 lines
331 B
TypeScript

/**
* Creates an HTML Element from a given string. Only use this when using
* Preact isn't practical.
*/
export function createElementFromString<T extends Element>(input: string): T {
const template = document.createElement("template");
template.innerHTML = input.trim();
return template.content.firstElementChild as T;
}