I do not run your code, but there are some strange things, maybe one of them can cause a problem or help clear the code so that the problem is more obvious.
temp sb_button: tempsb_button - node- node
sb_button newparent if, , sb_button_.parentNode parent - , parentNode readonly, , , - , . - ?
:, , , , cloneNode: node , node.
, , . , , ( sort, , ), , newparent newparent. , if-clauses, " " else. :.
for(var child = parent.firstChild; child; child = child.nextSibling)
if(child.id == curr_button.id) {
newparent.appendChild(child.cloneNode(true));
newparent.appendChild(prev_button.cloneNode(true));
} else if(child.id != prev_button.id) {
newparent.appendChild(child.cloneNode(true));
}
parent.parentNode.replaceChild(newparent, parent);
, , .