1/**
2 * Convert a template string into HTML DOM nodes
3 * @param {String} str The template string
4 * @return {Node} The template HTML
5 */
6var stringToHTML = function (str) {
7 var parser = new DOMParser();
8 var doc = parser.parseFromString(str, 'text/html');
9 return doc.body;
10};
11
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}
1Object.keys(obj).forEach(key => {
2 if (obj[key] === undefined) {
3 delete obj[key];
4 }
5});