replaceChild method
Implementation
@mustCallSuper
Node? replaceChild(Node newNode, Node oldNode) {
Node? replacedNode;
if (childNodes.contains(oldNode)) {
int referenceIndex = childNodes.indexOf(oldNode);
oldNode.parentNode = null;
replacedNode = oldNode;
childNodes[referenceIndex] = newNode;
if (newNode.isConnected) {
newNode.disconnectedCallback();
newNode.connectedCallback();
}
} else {
appendChild(newNode);
}
return replacedNode;
}