From 487ed0537b912d3f72917733dc1d26b0794e9649 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 9 Feb 2024 10:45:29 -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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5269905 Reviewed-by: David Baron Commit-Queue: Joey Arhar Cr-Commit-Position: refs/heads/main@{#1258629} --- .../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 00000000000000..5c2e70f87a6101 --- /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 5edff18614225d..47612e759eaa49 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();