LibWeb: Override HTMLFormElement::is_supported_property_name()

By implementing this method ourselves, we no longer go through
::supported_property_names() and skip both the vector allocation and
sorting, which we don't need to determine if a property name is present.
This commit is contained in:
Jelle Raaijmakers
2026-04-21 14:37:32 +02:00
committed by Tim Ledbetter
parent e63af74dda
commit 6171cb7bbf
Notes: github-actions[bot] 2026-04-21 13:04:00 +00:00
2 changed files with 14 additions and 0 deletions

View File

@@ -1011,6 +1011,19 @@ Optional<JS::Value> HTMLFormElement::item_value(size_t index) const
return {};
}
bool HTMLFormElement::is_supported_property_name(FlyString const& name) const
{
// NB: This is a simplified version of ::supported_property_names() that does not require sorting or allocations.
for (auto const& candidate : m_associated_elements) {
if (is_form_control(*candidate, *this) || is<HTMLImageElement>(*candidate)) {
if (first_is_one_of(name, candidate->id(), candidate->name()))
return true;
}
}
return m_past_names_map.contains(name);
}
// https://html.spec.whatwg.org/multipage/forms.html#the-form-element:supported-property-names
Vector<FlyString> HTMLFormElement::supported_property_names() const
{