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 whatwg#9045
  • Loading branch information
josepharhar committed Apr 10, 2023
1 parent 578def6 commit 4c081c0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -60034,8 +60034,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 true, 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 @@ -60054,6 +60057,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 @@ -82130,8 +82136,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 changes its <code data-x="attr-popover">popover</code>
attribute.</p>
</li>
</ol>
</li>
Expand Down Expand Up @@ -82554,18 +82560,27 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
</ol>
</li>

<li><p>If <var>element</var> is not <span>connected</span>, then throw a
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</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>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 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 4c081c0

Please sign in to comment.