fix of issue #619 and other similar, error in JSLikeHTMLElement: node no longer exists.

This commit is contained in:
Maryana Rozhankivska 2014-07-09 16:50:52 +03:00
parent 4247b37551
commit cc1ec61b85

17
inc/3rdparty/libraries/readability/Readability.php vendored Normal file → Executable file
View file

@ -679,6 +679,7 @@ class Readability
} else {
$topCandidate->innerHTML = $page->documentElement->innerHTML;
$page->documentElement->innerHTML = '';
$this->reinitBody();
$page->documentElement->appendChild($topCandidate);
}
} else {
@ -794,8 +795,7 @@ class Readability
{
// TODO: find out why element disappears sometimes, e.g. for this URL http://www.businessinsider.com/6-hedge-fund-etfs-for-average-investors-2011-7
// in the meantime, we check and create an empty element if it's not there.
if (!isset($this->body->childNodes)) $this->body = $this->dom->createElement('body');
$this->body->innerHTML = $this->bodyCache;
$this->reinitBody();
if ($this->flagIsActive(self::FLAG_STRIP_UNLIKELYS)) {
$this->removeFlag(self::FLAG_STRIP_UNLIKELYS);
@ -1134,5 +1134,18 @@ class Readability
public function removeFlag($flag) {
$this->flags = $this->flags & ~$flag;
}
/**
* Will recreate previously deleted body property
*
* @return void
*/
protected function reinitBody() {
if (!isset($this->body->childNodes)) {
$this->body = $this->dom->createElement('body');
}
$this->body->innerHTML = $this->bodyCache;
}
}
?>