1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:35:07 +00:00

LibWeb: Use cached element name and id where possible

Instead of looking up in the named node map, we can simply use the
cached name and ID on the element.
This commit is contained in:
Shannon Booth 2024-01-13 20:12:25 +13:00 committed by Andreas Kling
parent 41f84deb9f
commit 0695236408
11 changed files with 30 additions and 36 deletions

View file

@ -118,12 +118,10 @@ Vector<FlyString> HTMLCollection::supported_property_names() const
}
// 2. If element is in the HTML namespace and has a name attribute whose value is neither the empty string nor is in result, append elements name attribute value to result.
if (element->namespace_uri() == Namespace::HTML) {
if (auto maybe_name = element->attribute(HTML::AttributeNames::name); maybe_name.has_value()) {
auto name = maybe_name.release_value();
if (!name.is_empty() && !result.contains_slow(name))
result.append(name);
}
if (element->namespace_uri() == Namespace::HTML && element->name().has_value()) {
auto name = element->name().value();
if (!name.is_empty() && !result.contains_slow(name))
result.append(move(name));
}
}