code: public Node replaceChild(Node newChild, Node oldChild) throws DOMException
    {
  
      if (oldChild == null || oldChild.getParentNode() != this)
        return null;
  
      ElemTemplateElement newChildElem = ((ElemTemplateElement) newChild);
      ElemTemplateElement oldChildElem = ((ElemTemplateElement) oldChild);
  
      // Fix up previous sibling.
      ElemTemplateElement prev =
        (ElemTemplateElement) oldChildElem.getPreviousSibling();
  
      if (null != prev)
        prev.m_nextSibling = newChildElem;
  
      // Fix up parent (this)
      if (m_firstChild == oldChildElem)
        m_firstChild = newChildElem;
  
      newChildElem.m_parentNode = this;
      oldChildElem.m_parentNode = null;
      newChildElem.m_nextSibling = oldChildElem.m_nextSibling;
      oldChildElem.m_nextSibling = null;
  
      // newChildElem.m_stylesheet = oldChildElem.m_stylesheet;
      // oldChildElem.m_stylesheet = null;
      return newChildElem;
    }
docs: Replace the old child with a new child.
  
  @param newChild New child to replace with
  @param oldChild Old child to be replaced
  
  @return The new child
  
  @throws DOMException