| @@ 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 | } |
|
| @@ 820-843 (lines=24) @@ | ||
| 817 | } |
|
| 818 | ||
| 819 | // Remove head element, preserving child nodes. |
|
| 820 | if ( |
|
| 821 | $removeExtraHeadTag |
|
| 822 | && |
|
| 823 | $this->node->parentNode instanceof \DOMElement |
|
| 824 | && |
|
| 825 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
| 826 | ) { |
|
| 827 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
| 828 | if ($this->node->parentNode->ownerDocument !== null) { |
|
| 829 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
| 830 | if ($html !== null) { |
|
| 831 | /** @var \DOMNode $html */ |
|
| 832 | while ($html->childNodes->length > 0) { |
|
| 833 | $tmpNode = $html->childNodes->item(0); |
|
| 834 | if ($tmpNode !== null) { |
|
| 835 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 836 | $fragment->appendChild($tmpNode); |
|
| 837 | } |
|
| 838 | } |
|
| 839 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 840 | $html->parentNode->replaceChild($fragment, $html); |
|
| 841 | } |
|
| 842 | } |
|
| 843 | } |
|
| 844 | ||
| 845 | return $newDocument; |
|
| 846 | } |
|