summaryrefslogtreecommitdiff
path: root/src/Nodes
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2019-05-26 12:09:39 +0100
committerAndres Rey <[email protected]>2019-05-26 12:09:39 +0100
commitc34b6209d68837e3283af821381caee62e0a8aeb (patch)
treeb0381e14f1561b99a2ccd92c516069650e02c096 /src/Nodes
parent10e234f128798c46e60f5d7b3fc3e4752b46546f (diff)
Add safecheck for getFirstElementChild and replace another instance of firstChild
Diffstat (limited to 'src/Nodes')
-rw-r--r--src/Nodes/NodeTrait.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Nodes/NodeTrait.php b/src/Nodes/NodeTrait.php
index ccc82ab..9ef1fa2 100644
--- a/src/Nodes/NodeTrait.php
+++ b/src/Nodes/NodeTrait.php
@@ -181,11 +181,11 @@ trait NodeTrait
/**
* Override for native hasAttribute.
*
- * @see getAttribute
- *
* @param $attributeName
*
* @return bool
+ * @see getAttribute
+ *
*/
public function hasAttribute($attributeName)
{
@@ -566,9 +566,11 @@ trait NodeTrait
*/
public function getFirstElementChild()
{
- foreach ($this->childNodes as $node) {
- if ($node instanceof \DOMElement) {
- return $node;
+ if ($this->childNodes instanceof \Traversable) {
+ foreach ($this->childNodes as $node) {
+ if ($node instanceof \DOMElement) {
+ return $node;
+ }
}
}