From c7351d93ef2828e88aad20d44051a16fedf6a339 Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Sat, 10 Dec 2016 19:04:23 +0000 Subject: Fixed wrong iteration on hasSingleChildBlockElement. Funny how one single line in JS turns into 10 in PHP. Not because PHP, more like because I'm a sub par dev :F --- src/HTMLParser.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 92a85a4..5b2aa2f 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -889,17 +889,19 @@ class HTMLParser private function hasSingleChildBlockElement(Readability $node) { + $result = false; if ($node->hasChildren()) { /** @var Readability $child */ foreach ($node->getChildren() as $child) { if (in_array($child->getTagName(), $this->divToPElements)) { - return true; + $result = true; } else { - return $this->hasSingleChildBlockElement($child); + // If any of the hasSingleChildBlockElement calls return true, return true then. + $result = ($result || $this->hasSingleChildBlockElement($child)); } } } - return true; + return $result; } } -- cgit v1.2.3