Add parseHTML
Some checks are pending
Build DevBuild / Build (push) Waiting to run
Sync to Codeberg / codeberg (push) Waiting to run
test / test (push) Waiting to run

This commit is contained in:
Daniel 2025-05-10 04:10:06 +02:00
parent 13ca3bce09
commit 9fbc5a2b6e

View file

@ -792,6 +792,15 @@ export const DOMHolder = {
if (theRemoteScript != null) if (theRemoteScript != null)
theRemoteScript.remove(); theRemoteScript.remove();
}, },
parseHTML(html: string, asFragment = false) {
const template = document.createElement("template");
template.innerHTML = html.trim();
if (asFragment) {
return template.content.cloneNode(true);
}
const { childNodes } = template.content;
return childNodes.length === 1 ? childNodes[0] : childNodes;
},
}; };
class DOMWrapper { class DOMWrapper {