mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +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:
parent
41f84deb9f
commit
0695236408
11 changed files with 30 additions and 36 deletions
|
@ -1285,7 +1285,7 @@ JS::NonnullGCPtr<HTMLCollection> Document::anchors()
|
|||
{
|
||||
if (!m_anchors) {
|
||||
m_anchors = HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [](Element const& element) {
|
||||
return is<HTML::HTMLAnchorElement>(element) && element.has_attribute(HTML::AttributeNames::name);
|
||||
return is<HTML::HTMLAnchorElement>(element) && element.name().has_value();
|
||||
});
|
||||
}
|
||||
return *m_anchors;
|
||||
|
@ -1828,7 +1828,7 @@ Element* Document::find_a_potential_indicated_element(FlyString const& fragment)
|
|||
// whose value is equal to fragment, then return the first such element in tree order.
|
||||
Element* element_with_name = nullptr;
|
||||
root().for_each_in_subtree_of_type<Element>([&](Element const& element) {
|
||||
if (element.attribute(HTML::AttributeNames::name) == fragment) {
|
||||
if (element.name() == fragment) {
|
||||
element_with_name = const_cast<Element*>(&element);
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue