Closed
Description
Description
Live reproduce: https://3v4l.org/AgHLn
The following code:
<?php
$html = <<<HTML
<!DOCTYPE HTML>
<html>
<body>
<div></div>
</body>
</html>
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$divs = iterator_to_array($dom->getElementsByTagName('div')->getIterator());
foreach ($divs as $div) {
$fragment = $dom->createDocumentFragment();
$fragment->appendXML('<p>Hi!</p>');
$div->replaceWith(...$fragment->childNodes);
}
throws DOMException: Not Found Error
since 8.2.6 and 8.1.19.
Probably related to #11288.
PHP Version
PHP 8.2.6, 8.1.19
Operating System
FreeBSD 12.4, Windows 10 x64