Need to turn an HTML string into usable DOM nodes? Assign it to a temporary element’s innerHTML, then extract the parsed nodes. The markup may need cleanup and browser-required wrappers first. section 12.1.1
A reliable conversion follows these steps:
- Make the string valid HTML, including expanding self-closing tags that HTML does not support in that form. section 12.1.1
- Wrap elements in the containers browser parsing rules require; for example, options need a select. section 12.1.1
- Set the temporary element’s innerHTML, then extract its child nodes. section 12.1.1
let div = (doc || document).createElement("div");
div.innerHTML = mapEntry[1] + htmlString + mapEntry[2]
See the innerHTML assignment used to place wrapped markup in a temporary div. section 12.1.1

