| @@ 519-540 (lines=22) @@ | ||
| 516 | $this->node = $newNode; |
|
| 517 | ||
| 518 | // Remove head element, preserving child nodes. (again) |
|
| 519 | if ( |
|
| 520 | $this->node->parentNode instanceof \DOMElement |
|
| 521 | && |
|
| 522 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
| 523 | ) { |
|
| 524 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
| 525 | if ($this->node->parentNode->ownerDocument !== null) { |
|
| 526 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
| 527 | if ($html !== null) { |
|
| 528 | /** @var \DOMNode $html */ |
|
| 529 | while ($html->childNodes->length > 0) { |
|
| 530 | $tmpNode = $html->childNodes->item(0); |
|
| 531 | if ($tmpNode !== null) { |
|
| 532 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 533 | $fragment->appendChild($tmpNode); |
|
| 534 | } |
|
| 535 | } |
|
| 536 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 537 | $html->parentNode->replaceChild($fragment, $html); |
|
| 538 | } |
|
| 539 | } |
|
| 540 | } |
|
| 541 | ||
| 542 | return $this; |
|
| 543 | } |
|
| @@ 649-672 (lines=24) @@ | ||
| 646 | } |
|
| 647 | ||
| 648 | // Remove head element, preserving child nodes. |
|
| 649 | if ( |
|
| 650 | $removeExtraHeadTag |
|
| 651 | && |
|
| 652 | $this->node->parentNode instanceof \DOMElement |
|
| 653 | && |
|
| 654 | $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() |
|
| 655 | ) { |
|
| 656 | $html = $this->node->parentNode->getElementsByTagName('head')[0]; |
|
| 657 | if ($this->node->parentNode->ownerDocument !== null) { |
|
| 658 | $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment(); |
|
| 659 | if ($html !== null) { |
|
| 660 | /** @var \DOMNode $html */ |
|
| 661 | while ($html->childNodes->length > 0) { |
|
| 662 | $tmpNode = $html->childNodes->item(0); |
|
| 663 | if ($tmpNode !== null) { |
|
| 664 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 665 | $fragment->appendChild($tmpNode); |
|
| 666 | } |
|
| 667 | } |
|
| 668 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 669 | $html->parentNode->replaceChild($fragment, $html); |
|
| 670 | } |
|
| 671 | } |
|
| 672 | } |
|
| 673 | ||
| 674 | return $newDocument; |
|
| 675 | } |
|