Created
April 21, 2025 17:42
-
-
Save o-t-w/aefa44fd1f5c05f74e811c487a3d9ddc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createNode(html) { | |
const nodeList = Document.parseHTMLUnsafe(html).body.childNodes; | |
const fragment = new DocumentFragment(); | |
Array.from(nodeList).forEach(node => { | |
fragment.appendChild(node); | |
}); | |
return fragment; | |
} | |
document.body.append(createNode('<h2>hello</h2><p>world</p>')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment