@@ 251-272 (lines=22) @@ | ||
248 | $this->node = $newNode; |
|
249 | ||
250 | // Remove head element, preserving child nodes. (again) |
|
251 | if ( |
|
252 | $this->node->parentNode instanceof \DOMElement |
|
253 | && |
|
254 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
255 | ) { |
|
256 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
257 | if ($this->node->parentNode->ownerDocument !== null) { |
|
258 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
259 | if ($html !== null) { |
|
260 | /** @var \DOMNode $html */ |
|
261 | while ($html->childNodes->length > 0) { |
|
262 | $tmpNode = $html->childNodes->item(0); |
|
263 | if ($tmpNode !== null) { |
|
264 | /** @noinspection UnusedFunctionResultInspection */ |
|
265 | $fragment->appendChild($tmpNode); |
|
266 | } |
|
267 | } |
|
268 | /** @noinspection UnusedFunctionResultInspection */ |
|
269 | $html->parentNode->replaceChild($fragment, $html); |
|
270 | } |
|
271 | } |
|
272 | } |
|
273 | ||
274 | return $this; |
|
275 | } |
|
@@ 798-821 (lines=24) @@ | ||
795 | } |
|
796 | ||
797 | // Remove head element, preserving child nodes. |
|
798 | if ( |
|
799 | $removeExtraHeadTag |
|
800 | && |
|
801 | $this->node->parentNode instanceof \DOMElement |
|
802 | && |
|
803 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
804 | ) { |
|
805 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
806 | if ($this->node->parentNode->ownerDocument !== null) { |
|
807 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
808 | if ($html !== null) { |
|
809 | /** @var \DOMNode $html */ |
|
810 | while ($html->childNodes->length > 0) { |
|
811 | $tmpNode = $html->childNodes->item(0); |
|
812 | if ($tmpNode !== null) { |
|
813 | /** @noinspection UnusedFunctionResultInspection */ |
|
814 | $fragment->appendChild($tmpNode); |
|
815 | } |
|
816 | } |
|
817 | /** @noinspection UnusedFunctionResultInspection */ |
|
818 | $html->parentNode->replaceChild($fragment, $html); |
|
819 | } |
|
820 | } |
|
821 | } |
|
822 | ||
823 | return $newDocument; |
|
824 | } |