replaceChild method

  1. @mustCallSuper
Node? replaceChild(
  1. Node newNode,
  2. Node oldNode
)
inherited

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;
}