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