]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fix of issue #619 and other similar, error in JSLikeHTMLElement: node no longer exists.
authorMaryana Rozhankivska <mariroz@mr.lviv.ua>
Wed, 9 Jul 2014 13:50:52 +0000 (16:50 +0300)
committerMaryana Rozhankivska <mariroz@mr.lviv.ua>
Wed, 9 Jul 2014 13:50:52 +0000 (16:50 +0300)
inc/3rdparty/libraries/readability/Readability.php [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index d0f09d7..9e77dc5
@@ -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;
        }
+       
+       /**\r
+        * Will recreate previously deleted body property\r
+        *\r
+        * @return void\r
+        */\r
+       protected function reinitBody() {\r
+               if (!isset($this->body->childNodes)) {\r
+                       $this->body = $this->dom->createElement('body');\r
+               }\r
+               $this->body->innerHTML = $this->bodyCache;\r
+       }
+               
 }
 ?>
\ No newline at end of file