Skip to content

Commit

Permalink
Bug 1834519 - Don't throw when popovers/dialogs are in requested stat…
Browse files Browse the repository at this point in the history
…e. r=emilio

Update to be in line with spec discussions at
whatwg/html#9142

Differential Revision: https://phabricator.services.mozilla.com/D178782
  • Loading branch information
ziransun committed May 25, 2023
1 parent d4860b1 commit b06dacf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 13 additions & 6 deletions dom/html/HTMLDialogElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ void HTMLDialogElement::Close(

void HTMLDialogElement::Show(ErrorResult& aError) {
if (Open()) {
return;
if (!IsInTopLayer()) {
return;
}
return aError.ThrowInvalidStateError(
"Cannot call show() on an open modal dialog.");
}

if (IsPopoverOpen()) {
Expand Down Expand Up @@ -121,13 +125,16 @@ void HTMLDialogElement::UnbindFromTree(bool aNullParent) {
}

void HTMLDialogElement::ShowModal(ErrorResult& aError) {
if (!IsInComposedDoc()) {
return aError.ThrowInvalidStateError("Dialog element is not connected");
}

if (Open()) {
if (IsInTopLayer()) {
return;
}
return aError.ThrowInvalidStateError(
"Dialog element already has an 'open' attribute");
"Cannot call showModal() on an open non-modal dialog.");
}

if (!IsInComposedDoc()) {
return aError.ThrowInvalidStateError("Dialog element is not connected");
}

if (IsPopoverOpen()) {
Expand Down

This file was deleted.

0 comments on commit b06dacf

Please sign in to comment.