diff options
author | Andrew Dolgov <[email protected]> | 2019-08-16 12:53:25 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-08-16 12:53:25 +0300 |
commit | 24f55d5b919d4b39664b245e51c1d7b984a9966c (patch) | |
tree | 85805ec72804ef28b0f9a59f0973fc8b5d650362 /plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php | |
parent | 0e3b71c5351d46d7192dc6df015880059f34a839 (diff) |
update readability library
Diffstat (limited to 'plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php')
-rw-r--r-- | plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php b/plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php index 7a1f18ee4..cbf78bae0 100644 --- a/plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php +++ b/plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeUtility.php @@ -5,6 +5,7 @@ namespace andreskrey\Readability\Nodes; use andreskrey\Readability\Nodes\DOM\DOMDocument; use andreskrey\Readability\Nodes\DOM\DOMElement; use andreskrey\Readability\Nodes\DOM\DOMNode; +use andreskrey\Readability\Nodes\DOM\DOMNodeList; /** * Class NodeUtility. @@ -157,4 +158,23 @@ class NodeUtility return ($originalNode) ? $originalNode->nextSibling : $originalNode; } + + /** + * Remove all empty DOMNodes from DOMNodeLists. + * + * @param \DOMNodeList $list + * + * @return DOMNodeList + */ + public static function filterTextNodes(\DOMNodeList $list) + { + $newList = new DOMNodeList(); + foreach ($list as $node) { + if ($node->nodeType !== XML_TEXT_NODE || mb_strlen(trim($node->nodeValue))) { + $newList->add($node); + } + } + + return $newList; + } } |