mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:37:45 +00:00
LibWeb: Add Element::for_each_attribute(Function<void(Attr const&)>)
This is useful when you are wanting to interate over attributes and need more information than just the name and value.
This commit is contained in:
parent
a8fd4fab00
commit
45b63b463a
2 changed files with 11 additions and 4 deletions
|
@ -1885,12 +1885,17 @@ void Element::set_prefix(Optional<FlyString> value)
|
||||||
m_qualified_name.set_prefix(move(value));
|
m_qualified_name.set_prefix(move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Element::for_each_attribute(Function<void(Attr const&)> callback) const
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < m_attributes->length(); ++i)
|
||||||
|
callback(*m_attributes->item(i));
|
||||||
|
}
|
||||||
|
|
||||||
void Element::for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)> callback) const
|
void Element::for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)> callback) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_attributes->length(); ++i) {
|
for_each_attribute([&callback](Attr const& attr) {
|
||||||
auto const* attribute = m_attributes->item(i);
|
callback(attr.name(), attr.value().to_deprecated_string());
|
||||||
callback(attribute->name(), attribute->value().to_deprecated_string());
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout::NodeWithStyle* Element::layout_node()
|
Layout::NodeWithStyle* Element::layout_node()
|
||||||
|
|
|
@ -137,6 +137,8 @@ public:
|
||||||
int client_width() const;
|
int client_width() const;
|
||||||
int client_height() const;
|
int client_height() const;
|
||||||
|
|
||||||
|
void for_each_attribute(Function<void(Attr const&)>) const;
|
||||||
|
|
||||||
void for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)>) const;
|
void for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)>) const;
|
||||||
|
|
||||||
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue