mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-27 01:56:21 +00:00
Bindings: Make item_value return an Optional<JS::Value>
This removes some ambiguity about what the return value should be if the index is out of range. Previously, we would sometimes return a JS null, and other times a JS undefined. It will also let us fold together the checks for whether an index is a supported property index, followed by getting the value just afterwards.
This commit is contained in:
committed by
Andreas Kling
parent
9b59dc5e8b
commit
c5c1a8fcc7
@@ -935,11 +935,13 @@ bool HTMLFormElement::is_supported_property_index(u32 index) const
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-item
|
||||
JS::Value HTMLFormElement::item_value(size_t index) const
|
||||
Optional<JS::Value> HTMLFormElement::item_value(size_t index) const
|
||||
{
|
||||
// To determine the value of an indexed property for a form element, the user agent must return the value returned by
|
||||
// the item method on the elements collection, when invoked with the given index as its argument.
|
||||
return elements()->item(index);
|
||||
if (auto value = elements()->item(index))
|
||||
return value;
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-form-element:supported-property-names
|
||||
|
||||
Reference in New Issue
Block a user