From 7dcf958a56c43df83b972dc7c75f1cd58f69b134 Mon Sep 17 00:00:00 2001 From: Anders Pedersen Date: Thu, 21 Sep 2023 15:00:13 +0000 Subject: [PATCH] Added null check safeguard --- src/Dom/Parser.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Dom/Parser.php b/src/Dom/Parser.php index 5802edd..c6706ed 100644 --- a/src/Dom/Parser.php +++ b/src/Dom/Parser.php @@ -94,11 +94,13 @@ public function parse(Options $options, Content $content, int $size): AbstractNo /** @var \PHPHtmlParser\Dom\Node\HtmlNode|null $node */ $node = $tagDTO->getNode(); - $activeNode->addChild($node); + if ($node !== null) { + $activeNode->addChild($node); - // check if node is self closing - if (!$node->getTag()->isSelfClosing()) { - $activeNode = $node; + // check if node is self closing + if (!$node->getTag()->isSelfClosing()) { + $activeNode = $node; + } } } elseif ( $options->isWhitespaceTextNode() ||