function htmlToElem(html) { let temp = document.createElement('template'); html = html.trim(); // Never return a space text node as a result temp.innerHTML = html; return temp.content.firstChild; }; // Unlike setInnerHtml, this patches the Dom in place function setHtml(elm, html) { var htmlElem = htmlToElem(html); window.dispatchEvent(new Event('LiveBeforeMorphDOM')); morphdom(elm, html); window.dispatchEvent(new Event('LiveBeforeScriptReload')); // Re-add