@@ 260-284 (lines=25) @@ | ||
257 | $this->node = $newNode; |
|
258 | ||
259 | // Remove head element, preserving child nodes. (again) |
|
260 | if ( |
|
261 | $this->node->parentNode instanceof \DOMElement |
|
262 | && |
|
263 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
264 | ) { |
|
265 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
266 | ||
267 | if ( |
|
268 | $html !== null |
|
269 | && |
|
270 | $this->node->parentNode->ownerDocument |
|
271 | ) { |
|
272 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
273 | /** @var \DOMNode $html */ |
|
274 | while ($html->childNodes->length > 0) { |
|
275 | $tmpNode = $html->childNodes->item(0); |
|
276 | if ($tmpNode !== null) { |
|
277 | /** @noinspection UnusedFunctionResultInspection */ |
|
278 | $fragment->appendChild($tmpNode); |
|
279 | } |
|
280 | } |
|
281 | /** @noinspection UnusedFunctionResultInspection */ |
|
282 | $html->parentNode->replaceChild($fragment, $html); |
|
283 | } |
|
284 | } |
|
285 | ||
286 | return $this; |
|
287 | } |
|
@@ 848-876 (lines=29) @@ | ||
845 | } |
|
846 | ||
847 | // Remove head element, preserving child nodes. |
|
848 | if ( |
|
849 | $removeExtraHeadTag |
|
850 | && |
|
851 | $this->node->parentNode instanceof \DOMElement |
|
852 | && |
|
853 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
854 | ) { |
|
855 | $html = $this->node->parentNode->getElementsByTagName('head')[0] ?? null; |
|
856 | ||
857 | if ( |
|
858 | $html !== null |
|
859 | && |
|
860 | $this->node->parentNode->ownerDocument |
|
861 | ) { |
|
862 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
863 | ||
864 | /** @var \DOMNode $html */ |
|
865 | while ($html->childNodes->length > 0) { |
|
866 | $tmpNode = $html->childNodes->item(0); |
|
867 | if ($tmpNode !== null) { |
|
868 | /** @noinspection UnusedFunctionResultInspection */ |
|
869 | $fragment->appendChild($tmpNode); |
|
870 | } |
|
871 | } |
|
872 | ||
873 | /** @noinspection UnusedFunctionResultInspection */ |
|
874 | $html->parentNode->replaceChild($fragment, $html); |
|
875 | } |
|
876 | } |
|
877 | ||
878 | return $newDocument; |
|
879 | } |