From c541d14232d175a4036a466ab35db41b56411a9a Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Mon, 1 Dec 2025 15:51:23 +0000 Subject: [PATCH] LibWeb/HTML: Add spec asserts to HTMLDialogElement::set_close_watcher() Not sure when this change happened. This does include the fixed assert from here though: https://github.com/whatwg/html/commit/71e70e90066b5077bd128586f23867f590440e03 --- Libraries/LibWeb/HTML/HTMLDialogElement.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/HTML/HTMLDialogElement.cpp b/Libraries/LibWeb/HTML/HTMLDialogElement.cpp index 65034be43b7..b329793490a 100644 --- a/Libraries/LibWeb/HTML/HTMLDialogElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLDialogElement.cpp @@ -419,9 +419,17 @@ void HTMLDialogElement::close_the_dialog(Optional result, GC::Ptr(vm.argument(0).as_object()); @@ -434,7 +442,8 @@ void HTMLDialogElement::set_close_watcher() 0, Utf16FlyString {}, &realm()); auto cancel_callback = realm().heap().allocate(*cancel_callback_function, realm()); m_close_watcher->add_event_listener_without_options(HTML::EventNames::cancel, DOM::IDLEventListener::create(realm(), cancel_callback)); - // - closeAction being to close the dialog given dialog, dialog's request close return value, and dialog's request close source element. + // - closeAction being to close the dialog given dialog, dialog's request close return value, and dialog's + // request close source element. auto close_callback_function = JS::NativeFunction::create( realm(), [this](JS::VM&) { close_the_dialog(m_request_close_return_value, m_request_close_source_element); @@ -444,8 +453,9 @@ void HTMLDialogElement::set_close_watcher() 0, Utf16FlyString {}, &realm()); auto close_callback = realm().heap().allocate(*close_callback_function, realm()); m_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback)); - // - getEnabledState being to return true if dialog's enable close watcher for requestClose() is true or dialog's computed closed-by state is not None; otherwise false. - // ADHOC: Implemented slightly differently to the spec, as the spec is unnecessarily complex. + // - getEnabledState being to return true if dialog's enable close watcher for request close is true or dialog's + // computed closed-by state is not None; otherwise false. + // AD-HOC: Implemented slightly differently to the spec, as the spec is unnecessarily complex. // FIXME: This should be set based on dialog closedby state, when implemented. m_close_watcher->set_enabled(m_is_modal); }