mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
781e6b4d21
Don't loop over all children to determine if the target node really is a child, just trust the parent pointer. Add tests.
20 lines
447 B
PHP
20 lines
447 B
PHP
--TEST--
|
|
replaceChild() where the new node is a grandparent of the old node
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
$document = new DOMDocument();
|
|
$a = $document->createElement('a');
|
|
$b = $document->createElement('b');
|
|
$c = $document->createElement('c');
|
|
$a->appendChild($b);
|
|
$b->appendChild($c);
|
|
try {
|
|
$b->replaceChild($a, $c);
|
|
} catch (DOMException $e) {
|
|
echo "DOMException: " . $e->getMessage();
|
|
}
|
|
--EXPECT--
|
|
DOMException: Hierarchy Request Error
|