summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibWeb/DOM/Element.cpp7
-rw-r--r--Userland/Libraries/LibWeb/DOM/Element.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Element.idl3
3 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp
index 8c526472b5..adb878149e 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Element.cpp
@@ -93,6 +93,13 @@ String Element::get_attribute(FlyString const& name) const
return attribute->value();
}
+// https://dom.spec.whatwg.org/#dom-element-getattributenode
+JS::GCPtr<Attr> Element::get_attribute_node(FlyString const& name) const
+{
+ // The getAttributeNode(qualifiedName) method steps are to return the result of getting an attribute given qualifiedName and this.
+ return m_attributes->get_attribute(name);
+}
+
// https://dom.spec.whatwg.org/#dom-element-setattribute
WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
{
diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h
index 0924bc78cc..c58f89b8ef 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.h
+++ b/Userland/Libraries/LibWeb/DOM/Element.h
@@ -72,6 +72,8 @@ public:
NamedNodeMap const* attributes() const { return m_attributes.ptr(); }
Vector<String> get_attribute_names() const;
+ JS::GCPtr<Attr> get_attribute_node(FlyString const& name) const;
+
DOMTokenList* class_list();
WebIDL::ExceptionOr<bool> matches(StringView selectors) const;
diff --git a/Userland/Libraries/LibWeb/DOM/Element.idl b/Userland/Libraries/LibWeb/DOM/Element.idl
index dd7f9863de..addfe89d8a 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.idl
+++ b/Userland/Libraries/LibWeb/DOM/Element.idl
@@ -1,4 +1,5 @@
#import <CSS/CSSStyleDeclaration.idl>
+#import <DOM/Attr.idl>
#import <DOM/ChildNode.idl>
#import <DOM/DOMTokenList.idl>
#import <DOM/InnerHTML.idl>
@@ -38,6 +39,8 @@ interface Element : Node {
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
+ Attr? getAttributeNode(DOMString qualifiedName);
+
HTMLCollection getElementsByTagName(DOMString tagName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString className);