diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-11-05 04:37:40 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-11-07 14:10:41 +0100 |
commit | 8066a67da29b8c88cc63d8bd825d31681dea3d54 (patch) | |
tree | 21ce8f99199ab606bc38a466ad22600c91e8a82f /Userland/Libraries | |
parent | 469ef22a22ed94cad843ddebc738b5f04ced1cf4 (diff) | |
download | serenity-8066a67da29b8c88cc63d8bd825d31681dea3d54.zip |
LibWeb: Implement Element.getAttributeNode
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.cpp | 7 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Element.idl | 3 |
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); |