src/Document.php
/**
     * Removes a node from its parent and adopts it and all its children.
     *
     * @internal
     *
     * @see https://dom.spec.whatwg.org/#concept-node-adopt
     */
Removes a node from its parent and adopts it and all its children.
@internal


Removes a node from its parent and adopts it and all its children . @internal
public function doAdoptNode(Node $node): void
    {
        $oldDocument = $node->nodeDocument;
        if ($node->parentNode) {
            $node->removeNode();
        }
        if ($this !== $oldDocument) {
            $iter = new NodeIterator($node, NodeFilter::SHOW_ALL);
            while (($nextNode = $iter->nextNode())) {
                $nextNode->nodeDocument = $this;
                if ($nextNode instanceof Element) {
                    foreach ($nextNode->getAttributeList() as $attr) {
                        $attr->nodeDocument = $this;
                    }
                }
            }
            $iter = new NodeIterator($node);
            while (($descendant = $iter->nextNode())) {
                if (method_exists($descendant, 'doAdoptingSteps')) {
                    $descendant->doAdoptingSteps($oldDocument);
                }
            }
        }
    }
public function doAdoptNode ( Node $ node ) : void { $ oldDocument = $ node -> nodeDocument ; if ( $ node -> parentNode ) { $ node -> removeNode ( ) ; } if ( $ this !== $ oldDocument ) { $ iter = new NodeIterator ( $ node , NodeFilter :: SHOW_ALL ) ; while ( ( $ nextNode = $ iter -> nextNode ( ) ) ) { $ nextNode -> nodeDocument = $ this ; if ( $ nextNode instanceof Element ) { foreach ( $ nextNode -> getAttributeList ( ) as $ attr ) { $ attr -> nodeDocument = $ this ; } } } $ iter = new NodeIterator ( $ node ) ; while ( ( $ descendant = $ iter -> nextNode ( ) ) ) { if ( method_exists ( $ descendant , 'doAdoptingSteps' ) ) { $ descendant -> doAdoptingSteps ( $ oldDocument ) ; } } } }
Removes a node from its parent and adopts it and all its children.
Removes a node from its parent and adopts it and all its children .
// 3.1.2. If inclusiveDescendant is an element, then set the node document of each // attribute in inclusiveDescendant’s attribute list to document. // For each descendant in node’s inclusive descendants, in // tree order, run the adopting steps with descendant and // oldDocument.