Skip to content

Commit 0511ae0

Browse files
authored
Dispatch beforetoggle & toggle events during dialog open/close/showModal
This attempts to fix #9733 by specifying that: - A dialog's `show()` steps should dispatch a `beforetoggle` cancellable event. - Followed by a queuing a non-cancellable `toggle` event. - A dialog's `showModal()` steps should dispatch a `beforetoggle` cancellable event. - Followed by a queuing non-cancellable `toggle` event. - The "close the dialog" steps should disaptch a non-cancellable `beforetoggle` event. - Followed by queuing a non-cancellable `toggle` event. Tests: web-platform-tests/wpt#44208.
1 parent 9025fb3 commit 0511ae0

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

source

+88
Original file line numberDiff line numberDiff line change
@@ -61734,6 +61734,49 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6173461734

6173561735
<div w-nodev>
6173661736

61737+
<p>Every <code>dialog</code> element has a <dfn>dialog toggle task tracker</dfn>, which is a
61738+
<span>toggle task tracker</span> or null, initially null.</p>
61739+
61740+
<p>To <dfn>queue a dialog toggle event task</dfn> given a <code>dialog</code> element
61741+
<var>element</var>, a string <var>oldState</var>, and a string <var>newState</var>:
61742+
61743+
<ol>
61744+
<li>
61745+
<p>If <var>element</var>'s <span>dialog toggle task tracker</span> is not null, then:</p>
61746+
61747+
<ol>
61748+
<li><p>Set <var>oldState</var> to <var>element</var>'s <span>dialog toggle task
61749+
tracker</span>'s <span data-x="toggle-task-old-state">old state</span>.</p></li>
61750+
61751+
<li><p>Remove <var>element</var>'s <span>dialog toggle task tracker</span>'s <span
61752+
data-x="toggle-task-task">task</span> from its <span>task queue</span>.</p></li>
61753+
61754+
<li><p>Set <var>element</var>'s <span>dialog toggle task tracker</span> to null.</p></li>
61755+
</ol>
61756+
</li>
61757+
61758+
<li>
61759+
<p><span>Queue an element task</span> given the <span>DOM manipulation task source</span> and
61760+
<var>element</var> to run the following steps:</p>
61761+
61762+
<ol>
61763+
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
61764+
data-x="event-toggle">toggle</code> at <var>element</var>, using <code>ToggleEvent</code>, with
61765+
the <code data-x="dom-ToggleEvent-oldState">oldState</code> attribute initialized to
61766+
<var>oldState</var> and the <code data-x="dom-ToggleEvent-newState">newState</code> attribute
61767+
initialized to <var>newState</var>.</p></li>
61768+
61769+
<li><p>Set <var>element</var>'s <span>dialog toggle task tracker</span> to null.</p></li>
61770+
</ol>
61771+
</li>
61772+
61773+
<li><p>Set <var>element</var>'s <span>dialog toggle task tracker</span> to a struct with <span
61774+
data-x="toggle-task-task">task</span> set to the just-queued <span
61775+
data-x="concept-task">task</span> and <span data-x="toggle-task-old-state">old state</span> set
61776+
to <var>oldState</var>.</p></li>
61777+
</ol>
61778+
61779+
6173761780
<p>The <dfn method for="HTMLDialogElement"><code data-x="dom-dialog-show">show()</code></dfn>
6173861781
method steps are:</p>
6173961782

@@ -61744,6 +61787,20 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6174461787
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute, then
6174561788
throw an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>
6174661789

61790+
<li><p>If the result of <span data-x="concept-event-fire">firing an event</span> named <code
61791+
data-x="event-beforetoggle">beforetoggle</code>, using <code>ToggleEvent</code>, with the <code
61792+
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, the <code
61793+
data-x="dom-ToggleEvent-oldState">oldState</code> attribute initialized to "<code
61794+
data-x="">closed</code>", and the <code data-x="dom-ToggleEvent-newState">newState</code>
61795+
attribute initialized to "<code data-x="">open</code>" at <var>this</var> is false, then
61796+
return.</p></li>
61797+
61798+
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute, then
61799+
return.</p></li>
61800+
61801+
<li><p><span>Queue a dialog toggle event task</span> given <var>subject</var>, "<code
61802+
data-x="">closed</code>", and "<code data-x="">open</code>".</p></li>
61803+
6174761804
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to <span>this</span>, whose
6174861805
value is the empty string.</p></li>
6174961806

@@ -61782,6 +61839,25 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6178261839
state</span>, then throw an <span>"<code>InvalidStateError</code>"</span>
6178361840
<code>DOMException</code>.</p></li>
6178461841

61842+
<li><p>If the result of <span data-x="concept-event-fire">firing an event</span> named <code
61843+
data-x="event-beforetoggle">beforetoggle</code>, using <code>ToggleEvent</code>, with the <code
61844+
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, the <code
61845+
data-x="dom-ToggleEvent-oldState">oldState</code> attribute initialized to "<code
61846+
data-x="">closed</code>", and the <code data-x="dom-ToggleEvent-newState">newState</code>
61847+
attribute initialized to "<code data-x="">open</code>" at <var>this</var> is false, then
61848+
return.</p></li>
61849+
61850+
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute,
61851+
then return.</p></li>
61852+
61853+
<li><p>If <span>this</span> is not <span>connected</span>, then return.</p></li>
61854+
61855+
<li><p>If <span>this</span> is in the <span data-x="popover-showing-state">popover showing
61856+
state</span>, then return.</p></li>
61857+
61858+
<li><p><span>Queue a dialog toggle event task</span> given <var>subject</var>, "<code
61859+
data-x="">closed</code>", and "<code data-x="">open</code>".</p></li>
61860+
6178561861
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to <span>this</span>, whose
6178661862
value is the empty string.</p></li>
6178761863

@@ -61915,6 +61991,18 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6191561991
<li><p>If <var>subject</var> does not have an <code data-x="attr-dialog-open">open</code>
6191661992
attribute, then return.</p></li>
6191761993

61994+
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
61995+
data-x="event-beforetoggle">beforetoggle</code>, using <code>ToggleEvent</code>, with the <code
61996+
data-x="dom-ToggleEvent-oldState">oldState</code> attribute initialized to "<code
61997+
data-x="">open</code>" and the <code data-x="dom-ToggleEvent-newState">newState</code> attribute
61998+
initialized to "<code data-x="">closed</code>" at <var>subject</var>.</p></li>
61999+
62000+
<li><p>If <var>subject</var> does not have an <code data-x="attr-dialog-open">open</code>
62001+
attribute, then return.</p></li>
62002+
62003+
<li><p><span>Queue a dialog toggle event task</span> given <var>subject</var>, "<code
62004+
data-x="">open</code>", and "<code data-x="">closed</code>".</p></li>
62005+
6191862006
<li><p>Remove <var>subject</var>'s <code data-x="attr-dialog-open">open</code>
6191962007
attribute.</p></li>
6192062008

0 commit comments

Comments
 (0)