From 5b39b77dfe5ed555130956f7f8515be2bce7e028 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 9 Feb 2024 09:52:55 -0800 Subject: [PATCH] Close the dialog element when the open attribute is removed This patch adds HTMLDialogElement::ParseAttribute which runs HTMLDialogElement::close when the open attribute is removed to prevent a bad state where the dialog is modal but hidden and inerting the rest of the document. Spec discussion is happening here: https://github.com/whatwg/html/issues/5802 Change-Id: Ib90736ced952d7aeadc791c6863c3ac2a55deb62 --- .../dialog-close-via-attribute.html | 59 +++++++++++++++++++ .../the-dialog-element/dialog-showModal.html | 4 +- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 html/semantics/interactive-elements/the-dialog-element/dialog-close-via-attribute.html diff --git a/html/semantics/interactive-elements/the-dialog-element/dialog-close-via-attribute.html b/html/semantics/interactive-elements/the-dialog-element/dialog-close-via-attribute.html new file mode 100644 index 000000000000000..5c2e70f87a6101c --- /dev/null +++ b/html/semantics/interactive-elements/the-dialog-element/dialog-close-via-attribute.html @@ -0,0 +1,59 @@ + + + + + + + + + +hello world + + diff --git a/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html b/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html index 5edff18614225d0..47612e759eaa499 100644 --- a/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html +++ b/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html @@ -161,11 +161,11 @@ assert_equals(topElement(), d11); // Removing the open attribute and running through the showModal() algorithm - // again should not promote d10 to the top. + // again should promote d10 to the top. d10.removeAttribute("open"); assert_equals(topElement(), d11); d10.showModal(); - assert_equals(topElement(), d11); + assert_equals(topElement(), d10); // Closing d11 with close() should cause d10 to be the topmost element. d11.close();