Append NodeList to HTML element
now, you can use element.append() and element.childNodes straightly. just like:
var container = document.getElementById("app-data");
var childNodes = toDom(songlist);
container.append(...childNodes)
function toDom(str) {
var tmp = document.createElement("div");
tmp.innerHTML = str;
return tmp.childNodes;
};
The problem is that Node.childNodes is a NodeList. So when you try to append it, it fails of course, because NodeList is not the same as Node. You could append child nodes one by one in loop:
var container = document.getElementById("app-data");
var childNodes = toDom(songlist);
for (var i = 0; i < childNodes.length; i++) {
container.appendChild(childNodes[i])
}