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:
parent
e63af74dda
commit
6171cb7bbf
2 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ private:
|
|||
// ^PlatformObject
|
||||
virtual Optional<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value named_item_value(FlyString const& name) const override;
|
||||
virtual bool is_supported_property_name(FlyString const&) const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
|
||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||
|
|
|
|||
Loading…
Reference in a new issue