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 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 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 get_attribute_names() const; + JS::GCPtr get_attribute_node(FlyString const& name) const; + DOMTokenList* class_list(); WebIDL::ExceptionOr 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 +#import #import #import #import @@ -38,6 +39,8 @@ interface Element : Node { [SameObject] readonly attribute NamedNodeMap attributes; sequence getAttributeNames(); + Attr? getAttributeNode(DOMString qualifiedName); + HTMLCollection getElementsByTagName(DOMString tagName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString className);