summaryrefslogtreecommitdiff
path: root/src/Readability.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-11-04 12:34:42 +0000
committerAndres Rey <[email protected]>2016-11-04 12:34:42 +0000
commited9a6df1196401555779e528958342cc20daa23e (patch)
tree9e1d1dee6c8afb2be8eaeeb11d704356da154d55 /src/Readability.php
parent9238420ea7bfb6975610739b3685005b9ac8e5e6 (diff)
Fixed logic to make it go through all the nodes and not just skip them (DUHHHHHHHHHHHH)
Diffstat (limited to 'src/Readability.php')
-rw-r--r--src/Readability.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Readability.php b/src/Readability.php
index 3810ba8..a9c1592 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -115,7 +115,7 @@ class Readability extends Element implements ReadabilityInterface
{
$node = $this->node->parentNode;
- return ($node) ? new static($node) : null;
+ return ($node) ? new self($node) : null;
}
/**
@@ -285,11 +285,11 @@ class Readability extends Element implements ReadabilityInterface
public function removeAndGetNext($node)
{
$nextNode = $this->getNextNode($node, true);
- $node->node->parentNode->removeChild($node);
+ $nextNode->node->parentNode->removeChild($node->node);
return $nextNode;
}
- private function getNextNode($originalNode, $ignoreSelfAndKids)
+ public function getNextNode($originalNode, $ignoreSelfAndKids = false)
{
/**
* Traverse the DOM from node to node, starting at the node passed in.
@@ -301,21 +301,21 @@ class Readability extends Element implements ReadabilityInterface
// First check for kids if those aren't being ignored
if (!$ignoreSelfAndKids && $originalNode->node->firstChild) {
- return $originalNode->node->firstChild;
+ return new self($originalNode->node->firstChild);
}
// Then for siblings...
if ($originalNode->node->nextSibling) {
- return $originalNode->node->nextSibling;
+ return new self($originalNode->node->nextSibling);
}
// And finally, move up the parent chain *and* find a sibling
// (because this is depth-first traversal, we will have already
// seen the parent nodes themselves).
do {
- $originalNode = $this->getParent();
+ $originalNode = $originalNode->getParent();
} while ($originalNode && !$originalNode->node->nextSibling);
- return $originalNode && $originalNode->node->nextSibling;
+ return ($originalNode) ? new self($originalNode->node->nextSibling) : $originalNode;
}
}