Skip to content

Commit

Permalink
Don't throw when popover/dialog is in requested state
Browse files Browse the repository at this point in the history
This patch makes the following changes:

- Don't throw exceptions when showPopover or hidePopover is called and the popover is already in the requested state.
- Don't throw exceptions when dialog.showModal, dialog.show, or dialog.close is called and the dialog is already in the requested state.
- Throw exceptions when trying to switch between modal and non-modal dialog modes via dialog.showModal or dialog.show.

Fixes #9045.
  • Loading branch information
josepharhar authored May 9, 2023
1 parent 2d68c83 commit ba956cb
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -60158,8 +60158,11 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
method steps are:</p>

<ol>
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute and the
<span>is modal</span> flag of <span>this</span> is false, then return.</p></li>

<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute, then
return.</p></li>
throw an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <span>this</span> is in the <span data-x="popover-showing-state">popover showing
state</span>, then throw an <span>"<code>InvalidStateError</code>"</span>
Expand All @@ -60181,6 +60184,9 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
data-x="dom-dialog-showModal">showModal()</code></dfn> method steps are:</p>

<ol>
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute and the
<span>is modal</span> flag of <span>this</span> is true, then return.</p></li>

<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute, then
throw an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

Expand Down Expand Up @@ -82313,8 +82319,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
<p class="note"><span>Check popover validity</span> is called again because running <span
data-x="hide-all-popovers-until">hide all popovers until</span> above could have fired the
<code data-x="event-beforetoggle">beforetoggle</code> event, and an event handler could have
disconnected this element or called <code data-x="dom-showPopover">showPopover()</code> on
this element.</p>
disconnected this element or changed its <code data-x="attr-popover">popover</code>
attribute.</p>
</li>
</ol>
</li>
Expand Down Expand Up @@ -82734,16 +82740,24 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
<p>If one of the following conditions is true</p>

<ul>
<li><p><var>element</var> is not <span>connected</span></p></li>

<li><p><var>expectedDocument</var> is not null and <var>element</var>'s <span>node
document</span> is not <var>expectedDocument</var></p></li>

<li><p><var>expectedToBeShowing</var> is true and <var>element</var>'s <span>popover visibility
state</span> is not <span data-x="popover-showing-state">showing</span></p></li>

<li><p><var>expectedToBeShowing</var> is false and <var>element</var>'s <span>popover
visibility state</span> is not <span data-x="popover-hidden-state">hidden</span></p></li>
</ul>

<p>then return false.</p>
</li>

<li>
<p>If one of the following conditions is true</p>

<ul>
<li><p><var>element</var> is not <span>connected</span></p></li>

<li><p><var>expectedDocument</var> is not null and <var>element</var>'s <span>node
document</span> is not <var>expectedDocument</var></p></li>

<li><p><var>element</var> is a <code>dialog</code> element and has an <code
data-x="attr-details-open">open</code> attribute</p></li>
Expand Down

0 comments on commit ba956cb

Please sign in to comment.