mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +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
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/shannonbooth
Commit: 0695236408
Pull-request: https://github.com/SerenityOS/serenity/pull/22732
11 changed files with 30 additions and 36 deletions
|
@ -902,8 +902,8 @@ Vector<FlyString> HTMLFormElement::supported_property_names() const
|
|||
|
||||
// 2. If candidate has a name attribute, add an entry to sourced names with that name attribute's value as the
|
||||
// string, candidate as the element, and name as the source.
|
||||
if (auto maybe_name = candidate->attribute(HTML::AttributeNames::name); maybe_name.has_value())
|
||||
sourced_names.append(SourcedName { maybe_name.value(), candidate, SourcedName::Source::Name, {} });
|
||||
if (candidate->name().has_value())
|
||||
sourced_names.append(SourcedName { candidate->name().value(), candidate, SourcedName::Source::Name, {} });
|
||||
}
|
||||
|
||||
// 3. For each img element candidate whose form owner is the form element:
|
||||
|
@ -920,8 +920,8 @@ Vector<FlyString> HTMLFormElement::supported_property_names() const
|
|||
|
||||
// 2. If candidate has a name attribute, add an entry to sourced names with that name attribute's value as the
|
||||
// string, candidate as the element, and name as the source.
|
||||
if (auto maybe_name = candidate->attribute(HTML::AttributeNames::name); maybe_name.has_value())
|
||||
sourced_names.append(SourcedName { maybe_name.value(), candidate, SourcedName::Source::Name, {} });
|
||||
if (candidate->name().has_value())
|
||||
sourced_names.append(SourcedName { candidate->name().value(), candidate, SourcedName::Source::Name, {} });
|
||||
}
|
||||
|
||||
// 4. For each entry past entry in the past names map add an entry to sourced names with the past entry's name as
|
||||
|
@ -984,8 +984,7 @@ WebIDL::ExceptionOr<JS::Value> HTMLFormElement::named_item_value(FlyString const
|
|||
if (!is_form_control(element, *this))
|
||||
return false;
|
||||
|
||||
// FIXME: DOM::Element::name() isn't cached
|
||||
return name == element.id() || name == element.attribute(HTML::AttributeNames::name);
|
||||
return name == element.id() || name == element.name();
|
||||
});
|
||||
|
||||
// 2. If candidates is empty, let candidates be a live RadioNodeList object containing all the img elements,
|
||||
|
@ -1000,8 +999,7 @@ WebIDL::ExceptionOr<JS::Value> HTMLFormElement::named_item_value(FlyString const
|
|||
if (element.form() != this)
|
||||
return false;
|
||||
|
||||
// FIXME: DOM::Element::name() isn't cached
|
||||
return name == element.id() || name == element.attribute(HTML::AttributeNames::name);
|
||||
return name == element.id() || name == element.name();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue