1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 20:24:57 +00:00

LibWeb: Use cached Element::id in HTMLFormControlsCollection

This commit is contained in:
Shannon Booth 2024-01-13 20:12:21 +13:00 committed by Andreas Kling
parent 44089ce284
commit cb9118efe3

View file

@ -48,7 +48,7 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
auto collection = collect_matching_elements();
for (auto const& element : collection) {
if (element->deprecated_attribute(HTML::AttributeNames::id) != deprecated_name && element->name() != deprecated_name)
if (element->id() != name && element->name() != deprecated_name)
continue;
if (matching_element) {
@ -68,12 +68,12 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
// 4. Otherwise, create a new RadioNodeList object representing a live view of the HTMLFormControlsCollection object, further filtered so that the only nodes in the
// RadioNodeList object are those that have either an id attribute or a name attribute equal to name. The nodes in the RadioNodeList object must be sorted in tree
// order. Return that RadioNodeList object.
return JS::make_handle(RadioNodeList::create(realm(), root(), LiveNodeList::Scope::Descendants, [deprecated_name](Node const& node) {
return JS::make_handle(RadioNodeList::create(realm(), root(), LiveNodeList::Scope::Descendants, [name, deprecated_name](Node const& node) {
if (!is<Element>(node))
return false;
auto const& element = verify_cast<Element>(node);
return element.deprecated_attribute(HTML::AttributeNames::id) == deprecated_name || element.name() == deprecated_name;
return element.id() == name || element.name() == deprecated_name;
}));
}