LibWeb/HTML: Implement and use "optional value"

Corresponds to f3444c23ff

Also import a test.
This commit is contained in:
Sam Atkins 2025-07-08 11:28:10 +01:00 committed by Tim Ledbetter
parent 22cc36eeaa
commit af17f38bbf
Notes: github-actions[bot] 2025-07-08 16:10:58 +00:00
9 changed files with 228 additions and 7 deletions

View file

@ -492,16 +492,14 @@ void HTMLDialogElement::invoker_command_steps(DOM::Element& invoker, String& com
// 2. If command is in the Close state and element has an open attribute,
// then close the dialog given element with invoker's optional value and invoker.
if (command == "close" && has_attribute(AttributeNames::open)) {
// FIXME: This assumes invoker is a button.
auto optional_value = invoker.get_attribute(AttributeNames::value);
auto const optional_value = as<FormAssociatedElement>(invoker).optional_value();
close_the_dialog(optional_value, invoker);
}
// 3. If command is in the Request Close state and element has an open attribute,
// then request to close the dialog element with invoker's optional value and invoker.
if (command == "request-close" && has_attribute(AttributeNames::open)) {
// FIXME: This assumes invoker is a button.
auto optional_value = invoker.get_attribute(AttributeNames::value);
auto const optional_value = as<FormAssociatedElement>(invoker).optional_value();
request_close_the_dialog(optional_value, invoker);
}