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
commit 0695236408
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00
11 changed files with 30 additions and 36 deletions

View file

@ -899,8 +899,8 @@ ByteString Node::debug_description() const
builder.appendff("<{}>", dom_node()->node_name());
if (dom_node()->is_element()) {
auto& element = static_cast<DOM::Element const&>(*dom_node());
if (auto id = element.get_attribute(HTML::AttributeNames::id); id.has_value())
builder.appendff("#{}", id.value());
if (element.id().has_value())
builder.appendff("#{}", element.id().value());
for (auto const& class_name : element.class_names())
builder.appendff(".{}", class_name);
}