Skip to content

Commit e71d7bc

Browse files
committed
Fix error in substituteWith if parent of node is null
1 parent 887b312 commit e71d7bc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Traits/ManipulationTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ public function destroy(?string $selector = null): self {
184184
public function substituteWith(string|NodeList|\DOMNode|callable $input): self {
185185
$this->manipulateNodesWithInput($input, function($node, $newNodes) {
186186
foreach ($newNodes as $newNode) {
187-
$node->parent()->replaceChild($newNode, $node);
187+
if ($node->parent()) {
188+
$node->parent()->replaceChild($newNode, $node);
189+
}
188190
}
189191
});
190192

0 commit comments

Comments
 (0)