14 lines
320 B
JavaScript
14 lines
320 B
JavaScript
|
//@ts-check
|
||
|
|
||
|
/**
|
||
|
* Generates valid dom elements from a string
|
||
|
* @param {string} htmlString
|
||
|
*/
|
||
|
export const generateDomFromString = (htmlString) =>
|
||
|
/** @type {HTMLElement} */ (
|
||
|
new DOMParser().parseFromString(`<div>${htmlString}</div>`, "text/html")
|
||
|
.firstChild
|
||
|
);
|
||
|
|
||
|
export default generateDomFromString;
|