Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug #81642: DOMChildNode::replaceWith() bug when replacing a node…
… with itself Closes GH-11363.
- Loading branch information
Showing
5 changed files
with
112 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--TEST-- | ||
Bug #81642 (DOMChildNode::replaceWith() bug when replacing a node with itself) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
|
||
// Replace with itself | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($target = $doc->createElement('test')); | ||
$target->replaceWith($target); | ||
var_dump($doc->saveXML()); | ||
|
||
// Replace with itself + another element | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($target = $doc->createElement('test')); | ||
$target->replaceWith($target, $doc->createElement('foo')); | ||
var_dump($doc->saveXML()); | ||
|
||
// Replace with text node | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($target = $doc->createElement('test')); | ||
$target->replaceWith($target, 'foo'); | ||
var_dump($doc->saveXML()); | ||
|
||
// Replace with text node variant 2 | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($target = $doc->createElement('test')); | ||
$target->replaceWith('bar', $target, 'foo'); | ||
var_dump($doc->saveXML()); | ||
|
||
?> | ||
--EXPECT-- | ||
string(30) "<?xml version="1.0"?> | ||
<test/> | ||
" | ||
string(37) "<?xml version="1.0"?> | ||
<test/> | ||
<foo/> | ||
" | ||
string(34) "<?xml version="1.0"?> | ||
<test/> | ||
foo | ||
" | ||
string(38) "<?xml version="1.0"?> | ||
bar | ||
<test/> | ||
foo | ||
" |