summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Nodes/DOM/DOMNode.php1
-rw-r--r--src/Nodes/NodeTrait.php18
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Nodes/DOM/DOMNode.php b/src/Nodes/DOM/DOMNode.php
index f1944c4..7c3c4f3 100644
--- a/src/Nodes/DOM/DOMNode.php
+++ b/src/Nodes/DOM/DOMNode.php
@@ -6,6 +6,7 @@ use andreskrey\Readability\Nodes\NodeTrait;
/**
* @method getAttribute($attribute)
+ * @method hasAttribute($attribute)
*/
class DOMNode extends \DOMNode
{
diff --git a/src/Nodes/NodeTrait.php b/src/Nodes/NodeTrait.php
index 9f878ce..b4ca746 100644
--- a/src/Nodes/NodeTrait.php
+++ b/src/Nodes/NodeTrait.php
@@ -164,6 +164,24 @@ trait NodeTrait
}
/**
+ * Override for native hasAttribute
+ *
+ * @see getAttribute
+ *
+ * @param $attributeName
+ *
+ * @return bool
+ */
+ public function hasAttribute($attributeName)
+ {
+ if (!is_null($this->attributes)) {
+ return parent::hasAttribute($attributeName);
+ }
+
+ return false;
+ }
+
+ /**
* Get the ancestors of the current node.
*
* @param int|bool $maxLevel Max amount of ancestors to get. False for all of them