diff --git a/src/Readability.php b/src/Readability.php index 5654eb9..606aedf 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -951,10 +951,6 @@ class Readability $nodeToAppend = $this->dom->createElement('div'); try { - if ($siblingNode->getAttribute('id')) { - $nodeToAppend->setAttribute('id', $siblingNode->getAttribute('id')); - } - $nodeToAppend->setAttribute('alt', $siblingNodeName); $nodeToAppend->innerHTML = $siblingNode->innerHTML; } catch (Exception $e) { diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index e82c1d6..f1fd94a 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -379,4 +379,65 @@ class ReadabilityTest extends \PHPUnit_Framework_TestCase $this->assertContains('', $readability->getContent()->innerHTML); $this->assertContains('3D Touch', $readability->getTitle()->innerHTML); } + + /** + * This should generate an Exception "DOMElement::setAttribute(): ID post-60 already defined" + */ + public function testAppendIdAlreadyHere() + { + $data = ' + + + + + + +
+ + + + +
+
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are
+ This is an awesome text with some links, here there are +
+ +
+
+ + '; + + $readability = new ReadabilityTested($data, 'http://0.0.0.0'); + $readability->debug = true; + + $res = $readability->init(); + + $this->assertTrue($res); + $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent()); + $this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle()); + // $this->assertContains('', $readability->getContent()->innerHTML); + // $this->assertContains('3D Touch', $readability->getTitle()->innerHTML); + } }