diff options
author | Andres Rey <[email protected]> | 2017-11-30 19:27:06 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-11-30 19:27:06 +0000 |
commit | 2345497c61e486aa1220bf4e092de9aee1d1e285 (patch) | |
tree | 5b49c48f65c63318cb6f0da52e307d45f9c37138 | |
parent | 820f3d27e924c5eed6eb1fc3327ee8d1a11d8373 (diff) |
Replace regex with NodeUtility::$regexps equivalent
-rw-r--r-- | src/NodeClass/NodeClassTrait.php | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/NodeClass/NodeClassTrait.php b/src/NodeClass/NodeClassTrait.php index 4ab68d8..0fad1f2 100644 --- a/src/NodeClass/NodeClassTrait.php +++ b/src/NodeClass/NodeClassTrait.php @@ -329,12 +329,11 @@ trait NodeClassTrait public function isElementWithoutContent() { return $this instanceof DOMElement && - // /\x{00A0}|\s+/u TODO to be replaced with regexps array - mb_strlen(preg_replace('/\x{00A0}|\s+/u', '', $this->textContent)) === 0 && + mb_strlen(preg_replace(NodeUtility::$regexps['onlyWhitespace'], '', $this->textContent)) === 0 && ($this->childNodes->length === 0 || $this->childNodes->length === $this->getElementsByTagName('br')->length + $this->getElementsByTagName('hr')->length /* - * Special DOMDocument case: We also need to count how many DOMText we have inside the node. + * Special PHP DOMDocument case: We also need to count how many DOMText we have inside the node. * If there's an empty tag with an space inside and a BR (for example "<p> <br/></p>) counting only BRs and * HRs will will say that the example has 2 nodes, instead of one. This happens because in DOMDocument, * DOMTexts are also nodes (which doesn't happen in JS). So we need to also count how many DOMText we |