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

Loading…
Cancel
Save