After answering this question I am left wondering why removeChild
needs a parent element. After all, we could simply do
node.parentNode.removeChild(node);
As the parent node should be always directly available to the Javascript/DOM engine, it is not strictly necessary to supply the parent node of the node that is to be removed.
Of course I understand the principle that removeChild
is a method of a DOM node, but why doesn't something like document.removeNode
exist (that merely accepts an arbitrary node as parameter)?
EDIT: To be more clear, the question is: why does the JS engine need the parent node at all, if it already has the (unique) node that's to be removed?