@@ 232-253 (lines=22) @@ | ||
229 | $this->node = $newNode; |
|
230 | ||
231 | // Remove head element, preserving child nodes. (again) |
|
232 | if ( |
|
233 | $this->node->parentNode instanceof \DOMElement |
|
234 | && |
|
235 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
236 | ) { |
|
237 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
238 | if ($this->node->parentNode->ownerDocument !== null) { |
|
239 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
240 | if ($html !== null) { |
|
241 | /** @var \DOMNode $html */ |
|
242 | while ($html->childNodes->length > 0) { |
|
243 | $tmpNode = $html->childNodes->item(0); |
|
244 | if ($tmpNode !== null) { |
|
245 | /** @noinspection UnusedFunctionResultInspection */ |
|
246 | $fragment->appendChild($tmpNode); |
|
247 | } |
|
248 | } |
|
249 | /** @noinspection UnusedFunctionResultInspection */ |
|
250 | $html->parentNode->replaceChild($fragment, $html); |
|
251 | } |
|
252 | } |
|
253 | } |
|
254 | ||
255 | return $this; |
|
256 | } |
|
@@ 777-800 (lines=24) @@ | ||
774 | } |
|
775 | ||
776 | // Remove head element, preserving child nodes. |
|
777 | if ( |
|
778 | $removeExtraHeadTag |
|
779 | && |
|
780 | $this->node->parentNode instanceof \DOMElement |
|
781 | && |
|
782 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
783 | ) { |
|
784 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
785 | if ($this->node->parentNode->ownerDocument !== null) { |
|
786 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
787 | if ($html !== null) { |
|
788 | /** @var \DOMNode $html */ |
|
789 | while ($html->childNodes->length > 0) { |
|
790 | $tmpNode = $html->childNodes->item(0); |
|
791 | if ($tmpNode !== null) { |
|
792 | /** @noinspection UnusedFunctionResultInspection */ |
|
793 | $fragment->appendChild($tmpNode); |
|
794 | } |
|
795 | } |
|
796 | /** @noinspection UnusedFunctionResultInspection */ |
|
797 | $html->parentNode->replaceChild($fragment, $html); |
|
798 | } |
|
799 | } |
|
800 | } |
|
801 | ||
802 | return $newDocument; |
|
803 | } |