From 1c176922209b8a3002434a670b64a6f3683f812f Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Mon, 14 Nov 2016 16:45:12 +0000 Subject: Replacing old node when setting a new node tag --- src/HTMLParser.php | 5 ++--- src/Readability.php | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/HTMLParser.php b/src/HTMLParser.php index 0fae247..2e37d22 100644 --- a/src/HTMLParser.php +++ b/src/HTMLParser.php @@ -322,7 +322,6 @@ class HTMLParser $node->replaceChild($pNode); $node = $pNode; } elseif (!$this->hasSingleChildBlockElement($node)) { - // FIXME!!! $node->setNodeTag('p'); $this->elementsToScore[] = $node; } @@ -532,8 +531,8 @@ class HTMLParser * Turn it into a div so it doesn't get filtered out later by accident. */ - // TODO This is not working! Fix! -// $sibling->setNodeName('div'); + // TODO This is not working? Fix! + $sibling->setNodeTag('div'); } $import = $articleContent->importNode($sibling->getDOMNode(), true); diff --git a/src/Readability.php b/src/Readability.php index 0ad22e4..7fc0d2b 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -287,6 +287,8 @@ class Readability extends Element implements ReadabilityInterface // The import must be done on the firstChild of $new, since $new is a DOMDocument and not a DOMElement. $import = $this->node->ownerDocument->importNode($new->firstChild, true); $this->node->parentNode->replaceChild($import, $this->node); + + $this->node = $import; } /** -- cgit v1.2.3