1function htmlToElement(html) {
2 var template = document.createElement('template');
3 html = html.trim(); // Never return a text node of whitespace as the result
4 template.innerHTML = html;
5 return template.content.firstChild;
6}
1function createElementFromHTML(htmlString) {
2 var div = document.createElement('div');
3 div.innerHTML = htmlString.trim();
4
5 // Change this to div.childNodes to support multiple top-level nodes
6 return div.firstChild;
7}