Skip to content

Commit

Permalink
Change exception thrown when popover attribute is not present
Browse files Browse the repository at this point in the history
As discussed in web-platform-tests/wpt#38512. Those tests were reverted as part of web-platform-tests/wpt#38392.

Co-authored-by: Anne van Kesteren <[email protected]>
  • Loading branch information
josepharhar and annevk authored Feb 27, 2023
1 parent 3de95e7 commit 031d3f1
Showing 1 changed file with 47 additions and 62 deletions.
109 changes: 47 additions & 62 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -81856,17 +81856,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
<var>element</var> and a boolean <var>throwExceptions</var>:</p>

<ol>
<li>
<p>If the result of running <span>check popover validity</span> given <var>element</var> and
false is false, then:</p>

<ol>
<li><p><span>Assert</span>: <var>throwExceptions</var> is true.</p></li>

<li><P>Throw an <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code>.</p></li>
</ol>
</li>
<li><p>If the result of running <span>check popover validity</span> given <var>element</var>,
false, and <var>throwExceptions</var> is false, then return.</p></li>

<li><p><span>Assert</span>: <var>element</var> is not in <var>element</var>'s <span>node
document</span>'s <span>top layer</span>.</p></li>
Expand All @@ -81880,15 +81871,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
return.</p></li>

<li>
<p>If the result of running <span>check popover validity</span> given <var>element</var> and
false is false:</p>

<ol>
<li><p>If <var>throwExceptions</var> is true, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Otherwise, return.</p></li>
</ol>
<p>If the result of running <span>check popover validity</span> given <var>element</var>, false,
and <var>throwExceptions</var> is false, then return.</p>

<p class="note"><span>Check popover validity</span> is called again because firing the <code
data-x="event-beforetoggle">beforetoggle</code> event could have disconnected this element or
Expand Down Expand Up @@ -81919,14 +81903,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
<li>
<p>If <var>originalType</var> is not equal to the value of <var>element</var>'s <code
data-x="attr-popover">popover</code> attribute, or if the result of running <span>check
popover validity</span> given <var>element</var> and false is false:</p>

<ol>
<li><p>If <var>throwExceptions</var> is true, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Otherwise, return.</p></li>
</ol>
popover validity</span> given <var>element</var>, false, and <var>throwExceptions</var> is
false, then return.</p>

<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
Expand Down Expand Up @@ -82020,17 +81998,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
boolean <var>fireEvents</var>, and a boolean <var>throwExceptions</var>:</p>

<ol>
<li>
<p>If the result of running <span>check popover validity</span> given <var>element</var> and
true is false:</p>

<ol>
<li><p>If <var>throwExceptions</var> is true, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Otherwise, return.</p></li>
</ol>
</li>
<li><p>If the result of running <span>check popover validity</span> given <var>element</var>,
true, and <var>throwExceptions</var> is false, then return.</p></li>

<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.</p></li>

Expand Down Expand Up @@ -82074,15 +82043,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
attribute initialized to "<code data-x="">closed</code>" at <var>element</var>.</p></li>

<li>
<p>If the result of running <span>check popover validity</span> given <var>element</var> and
true is false:</p>

<ol>
<li><p>If <var>throwExceptions</var> is true, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Otherwise, return.</p></li>
</ol>
<p>If the result of running <span>check popover validity</span> given <var>element</var>,
true, and <var>throwExceptions</var> is false, then return.</p>

<p class="note"><span>Check popover validity</span> is called again because firing the <code
data-x="event-beforetoggle">beforetoggle</code> event could have disconnected this element or
Expand Down Expand Up @@ -82358,27 +82320,50 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
</ol>

<p>To <dfn>check popover validity</dfn> for an <span data-x="HTML elements">HTML element</span>
<var>element</var> given a boolean <var>expectedToBeShowing</var>, perform the following steps.
They return a boolean.</p>
<var>element</var> given a boolean <var>expectedToBeShowing</var> and a boolean
<var>throwExceptions</var>, perform the following steps. They throw an exception or return a
boolean.</p>

<ol>
<li><p>If <var>element</var>'s <code data-x="attr-popover">popover</code> attribute is in the
<span data-x="attr-popover-none-state">no popover state</span>, then return false.</p></li>
<li>
<p>If <var>element</var>'s <code data-x="attr-popover">popover</code> attribute is in the
<span data-x="attr-popover-none-state">no popover state</span>, then:</p>

<li><p>If <var>element</var> is not <span>connected</span>, then return false.</p></li>
<ol>
<li><p>If <var>throwExceptions</var> is true, then throw a
<span>"<code>NotSupportedError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <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>, then return
false.</p></li>
<li><p>Return false.</p></li>
</ol>
</li>

<li><p>If <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>, then return
false.</p></li>
<li>
<p>If one of the following conditions is true</p>

<li><p>If <var>element</var> is a <code>dialog</code> element and has the <code
data-x="attr-details-open">open</code> attribute, then return false.</p></li>
<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>

<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>

<li><p><var>element</var>'s <span>fullscreen flag</span> is set</p></li>
</ul>

<p>then:</p>

<ol>
<li><p>If <var>throwExceptions</var> is true, then throw a
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>If <var>element</var>'s <span>fullscreen flag</span> is set, then return false.</p></li>
<li><p>Return false.</p></li>
</ol>
</li>

<li><p>Return true.</p></li>
</ol>
Expand Down

0 comments on commit 031d3f1

Please sign in to comment.