You can use this to load untrusted third-party content and strip it of dangerous tags and attributes before including it iinnto your own document.
    Kind of a sandbox

    1. function parseHTML(str) {
    2. const frag = doc.implementation.createHTMLDocument(null);
    3. frag.body.innerHTML = str;
    4. return frag.body.childNodes;
    5. }