mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Implement Element.getAttributeNames
This commit is contained in:
parent
6b39c6b1bf
commit
4427386d5f
3 changed files with 14 additions and 0 deletions
|
@ -109,6 +109,18 @@ bool Element::has_attribute(const FlyString& name) const
|
|||
return m_attributes->get_attribute(name) != nullptr;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getattributenames
|
||||
Vector<String> Element::get_attribute_names() const
|
||||
{
|
||||
// The getAttributeNames() method steps are to return the qualified names of the attributes in this’s attribute list, in order; otherwise a new list.
|
||||
Vector<String> names;
|
||||
for (size_t i = 0; i < m_attributes->length(); ++i) {
|
||||
auto const* attribute = m_attributes->item(i);
|
||||
names.append(attribute->name());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
bool Element::has_class(const FlyString& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
void remove_attribute(const FlyString& name);
|
||||
size_t attribute_list_size() const { return m_attributes->length(); }
|
||||
NonnullRefPtr<NamedNodeMap> const& attributes() const { return m_attributes; }
|
||||
Vector<String> get_attribute_names() const;
|
||||
|
||||
RefPtr<DOMTokenList> const& class_list();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ interface Element : Node {
|
|||
boolean hasAttribute(DOMString qualifiedName);
|
||||
boolean hasAttributes();
|
||||
[SameObject] readonly attribute NamedNodeMap attributes;
|
||||
sequence<DOMString> getAttributeNames();
|
||||
|
||||
HTMLCollection getElementsByTagName(DOMString tagName);
|
||||
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue