/** * Replace current element with a new DOMNode * * @param $node * @return DOMNode|bool */ public function replaceWith(ElementInterface $element) { if ($this->node->parentNode !== null) { return $this->node->parentNode->replaceChild($element->getNode(), $this->getNode()); } return false; }