Below is the code fragment, there is something which I don't like:
function insert(el, child, before){
if ( before ) {
el.insertBefore(child, el.childNodes[0]);
} else {
el.appendChild(child);
}
}
Why not instead have two separate methods like insertBefore
and insertAfter
? what are the pros and cons of this and other approach?
Update:
I got this nice article explaining what I wanted.