mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 06:26:17 +00:00
Fix tests
`getInnerText` might receive a null DOMElement if the xpath or query return no element.
This commit is contained in:
+2
-4
@@ -235,8 +235,6 @@ class Readability implements LoggerAwareInterface
|
|||||||
* Load HTML in a DOMDocument.
|
* Load HTML in a DOMDocument.
|
||||||
* Apply Pre filters
|
* Apply Pre filters
|
||||||
* Cleanup HTML using Tidy (or not).
|
* Cleanup HTML using Tidy (or not).
|
||||||
*
|
|
||||||
* @return [type] [description]
|
|
||||||
*/
|
*/
|
||||||
private function loadHtml()
|
private function loadHtml()
|
||||||
{
|
{
|
||||||
@@ -1053,9 +1051,9 @@ class Readability implements LoggerAwareInterface
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getInnerText(\DOMElement $e, $normalizeSpaces = true, $flattenLines = false)
|
public function getInnerText(\DOMElement $e = null, $normalizeSpaces = true, $flattenLines = false)
|
||||||
{
|
{
|
||||||
if (!isset($e->textContent) || $e->textContent === '') {
|
if (null === $e || !isset($e->textContent) || $e->textContent === '') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user