diff options
-rw-r--r-- | src/HTMLParser.php | 14 | ||||
-rw-r--r-- | src/Readability.php | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 01c581b..92a85a4 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -889,12 +889,14 @@ class HTMLParser private function hasSingleChildBlockElement(Readability $node) { - /** @var Readability $child */ - foreach ($node->getChildren() as $child) { - if (in_array($child->getTagName(), $this->divToPElements)) { - $this->hasSingleChildBlockElement($child); - } else { - return false; + if ($node->hasChildren()) { + /** @var Readability $child */ + foreach ($node->getChildren() as $child) { + if (in_array($child->getTagName(), $this->divToPElements)) { + return true; + } else { + return $this->hasSingleChildBlockElement($child); + } } } diff --git a/src/Readability.php b/src/Readability.php index d647e63..e3122dd 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -417,11 +417,9 @@ class Readability extends Element implements ReadabilityInterface public function createNode(Readability $originalNode, $tagName) { $text = $originalNode->getTextContent(); - $newnode = $originalNode->node->ownerDocument->createElement($tagName, $text); + $newNode = $originalNode->node->ownerDocument->createElement($tagName, $text); - $return = $originalNode->node->appendChild($newnode); - - return new static($return); + return new static($newNode); } /** |