LibWeb: Do not assume field element is always a HTMLInputElement

Cast to a HTMLElement instead and retrieve the value attribute from
there instead.
This commit is contained in:
Kenneth Myhra 2023-02-13 10:59:19 +01:00 committed by Linus Groh
commit 562594c416
Notes: sideshowbarker 2024-07-17 00:26:29 +09:00

View file

@ -150,9 +150,9 @@ WebIDL::ExceptionOr<Optional<HashMapWithVectorOfFormDataEntryValue>> construct_e
// FIXME: 2. Create an entry with name and charset, and append it to entry list. // FIXME: 2. Create an entry with name and charset, and append it to entry list.
// 10. Otherwise, create an entry with name and the value of the field element, and append it to entry list. // 10. Otherwise, create an entry with name and the value of the field element, and append it to entry list.
else { else {
auto* input_element = dynamic_cast<HTML::HTMLInputElement*>(control.ptr()); auto* element = dynamic_cast<HTML::HTMLElement*>(control.ptr());
VERIFY(input_element); VERIFY(element);
TRY_OR_THROW_OOM(vm, form_data_entries.try_append(input_element->value())); TRY_OR_THROW_OOM(vm, form_data_entries.try_append(element->attribute("value"sv)));
TRY_OR_THROW_OOM(vm, entry_list.try_set(name, form_data_entries)); TRY_OR_THROW_OOM(vm, entry_list.try_set(name, form_data_entries));
} }