xref: /PHP-8.1/ext/dom/tests/gh11289.phpt (revision bffc7447)
1--TEST--
2GH-11289 (DOMException: Not Found Error introduced in 8.2.6, 8.1.19)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$html = <<<HTML
9<!DOCTYPE HTML>
10<html>
11<body>
12    <div></div>
13</body>
14</html>
15HTML;
16
17$dom = new DOMDocument();
18$dom->loadHTML($html);
19
20$divs = iterator_to_array($dom->getElementsByTagName('div')->getIterator());
21foreach ($divs as $div) {
22    $fragment = $dom->createDocumentFragment();
23    $fragment->appendXML('<p>Hi!</p>');
24    $div->replaceWith(...$fragment->childNodes);
25}
26
27var_dump(str_replace("\n", "", $dom->saveHTML()));
28?>
29--EXPECT--
30string(55) "<!DOCTYPE HTML><html><body>    <p>Hi!</p></body></html>"
31