| @@ 253-275 (lines=23) @@ | ||
| 250 | $this->node = $newNode; |
|
| 251 | ||
| 252 | // Remove head element, preserving child nodes. (again) |
|
| 253 | if ( |
|
| 254 | $this->node->parentNode instanceof \DOMElement |
|
| 255 | && |
|
| 256 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
| 257 | ) { |
|
| 258 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
| 259 | ||
| 260 | if ($this->node->parentNode->ownerDocument !== null) { |
|
| 261 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
| 262 | if ($html !== null) { |
|
| 263 | /** @var \DOMNode $html */ |
|
| 264 | while ($html->childNodes->length > 0) { |
|
| 265 | $tmpNode = $html->childNodes->item(0); |
|
| 266 | if ($tmpNode !== null) { |
|
| 267 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 268 | $fragment->appendChild($tmpNode); |
|
| 269 | } |
|
| 270 | } |
|
| 271 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 272 | $html->parentNode->replaceChild($fragment, $html); |
|
| 273 | } |
|
| 274 | } |
|
| 275 | } |
|
| 276 | ||
| 277 | return $this; |
|
| 278 | } |
|
| @@ 812-836 (lines=25) @@ | ||
| 809 | } |
|
| 810 | ||
| 811 | // Remove head element, preserving child nodes. |
|
| 812 | if ( |
|
| 813 | $removeExtraHeadTag |
|
| 814 | && |
|
| 815 | $this->node->parentNode instanceof \DOMElement |
|
| 816 | && |
|
| 817 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
| 818 | ) { |
|
| 819 | $html = $this->node->parentNode->getElementsByTagName('head')[0] ?? null; |
|
| 820 | ||
| 821 | if ($html !== null && $this->node->parentNode->ownerDocument !== null) { |
|
| 822 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
| 823 | ||
| 824 | /** @var \DOMNode $html */ |
|
| 825 | while ($html->childNodes->length > 0) { |
|
| 826 | $tmpNode = $html->childNodes->item(0); |
|
| 827 | if ($tmpNode !== null) { |
|
| 828 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 829 | $fragment->appendChild($tmpNode); |
|
| 830 | } |
|
| 831 | } |
|
| 832 | ||
| 833 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 834 | $html->parentNode->replaceChild($fragment, $html); |
|
| 835 | } |
|
| 836 | } |
|
| 837 | ||
| 838 | return $newDocument; |
|
| 839 | } |
|