Browse Source

Cloning templates is now slightly faster

master 1.0.4
Dustin Wilson 2 years ago
parent
commit
6caa4811e9
  1. 10
      lib/Node.php

10
lib/Node.php

@ -813,9 +813,11 @@ abstract class Node implements \Stringable {
// contents of the node should be appended to the wrapper element's content
// document fragment. Otherwise, clone the content document fragment instead.
if (!$parsing) {
$nodeWrapperContent = $node->ownerDocument->getWrapperNode($node)->content;
if ($nodeWrapperContent->hasChildNodes()) {
$copyWrapperContent->appendChild($this->cloneWrapperNode($nodeWrapperContent, $document->wrapperNode, true));
$copyWrapperContent = $copyWrapperContent->innerNode;
$nodeWrapperContent = $node->ownerDocument->getWrapperNode($node)->content->innerNode;
$childNodes = $nodeWrapperContent->childNodes;
foreach ($childNodes as $child) {
$copyWrapperContent->appendChild($this->cloneInnerNode($child, $document, true));
}
} else {
$copyContent = $copyWrapperContent->innerNode;
@ -835,7 +837,7 @@ abstract class Node implements \Stringable {
if ($node instanceof \DOMElement || $node instanceof \DOMDocumentFragment) {
$childNodes = $node->childNodes;
foreach ($childNodes as $child) {
$this->appendChildInner($copy, $this->cloneInnerNode($child, $document, true));
$this->appendChildInner($copy, $this->cloneInnerNode($child, $document, true, $parsing));
}
}
}

Loading…
Cancel
Save