summaryrefslogtreecommitdiff
path: root/src/Nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/Nodes')
-rw-r--r--src/Nodes/NodeTrait.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Nodes/NodeTrait.php b/src/Nodes/NodeTrait.php
index b4ca746..7661e15 100644
--- a/src/Nodes/NodeTrait.php
+++ b/src/Nodes/NodeTrait.php
@@ -473,9 +473,9 @@ trait NodeTrait
*/
public function isPhrasingContent()
{
- return $this->nodeType === XML_TEXT_NODE || !in_array($this->tagName, $this->phrasing_elems) ||
+ return $this->nodeType === XML_TEXT_NODE || !in_array($this->nodeName , $this->phrasing_elems) ||
(!is_null($this->childNodes) &&
- ($this->tagName === 'a' || $this->tagName === 'del' || $this->tagName === 'ins') &&
+ ($this->nodeName === 'a' || $this->nodeName === 'del' || $this->nodeName === 'ins') &&
array_reduce(iterator_to_array($this->childNodes), function ($carry, $node) {
return $carry || $node->isPhrasingContent();
})
@@ -493,4 +493,10 @@ trait NodeTrait
return !$this->hasAttribute('hidden');
}
+
+ public function isWhitespace()
+ {
+ return ($this->nodeType === XML_TEXT_NODE && mb_strlen(trim($this->textContent)) === 0) ||
+ ($this->nodeType === XML_ELEMENT_NODE && $this->nodeName === 'br');
+ }
}