Skip to content

Commit 791826b

Browse files
committed
Bug 1834519 - Don't throw when popovers/dialogs are in requested state. r=emilio
Update to be in line with spec discussions at whatwg/html#9142 Differential Revision: https://phabricator.services.mozilla.com/D178782
1 parent aac690a commit 791826b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

dom/html/HTMLDialogElement.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ void HTMLDialogElement::Close(
7171

7272
void HTMLDialogElement::Show(ErrorResult& aError) {
7373
if (Open()) {
74-
return;
74+
if (!IsInTopLayer()) {
75+
return;
76+
}
77+
return aError.ThrowInvalidStateError(
78+
"Cannot call show() on an open modal dialog.");
7579
}
7680

7781
if (IsPopoverOpen()) {
@@ -121,13 +125,16 @@ void HTMLDialogElement::UnbindFromTree(bool aNullParent) {
121125
}
122126

123127
void HTMLDialogElement::ShowModal(ErrorResult& aError) {
124-
if (!IsInComposedDoc()) {
125-
return aError.ThrowInvalidStateError("Dialog element is not connected");
126-
}
127-
128128
if (Open()) {
129+
if (IsInTopLayer()) {
130+
return;
131+
}
129132
return aError.ThrowInvalidStateError(
130-
"Dialog element already has an 'open' attribute");
133+
"Cannot call showModal() on an open non-modal dialog.");
134+
}
135+
136+
if (!IsInComposedDoc()) {
137+
return aError.ThrowInvalidStateError("Dialog element is not connected");
131138
}
132139

133140
if (IsPopoverOpen()) {

testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-no-throw-requested-state.html.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)