Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dialog to minimally handle open attribute mutations #10954

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
116 changes: 73 additions & 43 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -62234,15 +62234,6 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to <span>this</span>, whose
value is the empty string.</p></li>

<li><p><span>Assert</span>: <span>this</span>'s <span>node document</span>'s <span>open
dialogs list</span> does not <span data-x="list contains">contain</span>
<span>this</span>.</p></li>

<li><p>Add <span>this</span> to <span>this</span>'s <span>node document</span>'s <span>open
dialogs list</span>.</p></li>

<li><p><span>Set the dialog close watcher</span> with <span>this</span>.</p></li>

<li><p>Set <span>this</span>'s <span>previously focused element</span> to the
<span>focused</span> element.</p></li>

Expand Down Expand Up @@ -62388,20 +62379,28 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {

</div>

<p>The <code>dialog</code> <span>HTML element insertion steps</span>, given
<var>insertedNode</var>, are:</p>

<ol>
<li>
<p>If <var>insertedNode</var> has an <code data-x="attr-dialog-open">open</code> attribute:</p>

<ol>
<li><p>Run the <span>dialog setup steps</span> given <var>insertedNode</var>.</p></li>
</ol>
</li>
</ol>

<p>The <code>dialog</code> <span>HTML element removing steps</span>, given <var>removedNode</var>
and <var>oldParent</var>, are:</p>

<ol>
<li>
<p>If <var>removedNode</var>'s <span data-x="dialog-close-watcher">close watcher</span> is not
null, then:</p>
<p>If <var>removedNode</var> has an <code data-x="attr-dialog-open">open</code> attribute:</p>

<ol>
<li><p><span data-x="close-watcher-destroy">Destroy</span> <var>removedNode</var>'s <span
data-x="dialog-close-watcher">close watcher</span>.</p></li>

<li><p>Set <var>removedNode</var>'s <span data-x="dialog-close-watcher">close watcher</span> to
null.</p></li>
<li><p>Run the <span>dialog cleanup steps</span> given <var>removedNode</var>.</p></li>
</ol>
</li>

Expand All @@ -62410,9 +62409,25 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
the top layer immediately</span> given <var>removedNode</var>.</p></li>

<li><p>Set <span>is modal</span> of <var>removedNode</var> to false.</p></li>
</ol>

<p>The following <span data-x="concept-element-attributes-change-ext">attribute change
steps</span>, given <var>element</var>, <var>localName</var>, <var>oldValue</var>,
<var>value</var>, and <var>namespace</var> are used for <code>dialog</code> elements:</p>

<li><p><span data-x="list remove">Remove</span> <var>removedNode</var> from
<var>removedNode</var>'s <span>node document</span>'s <span>open dialogs list</span>.</p></li>
<ol>
<li><p>If <var>namespace</var> is not null, then return.</p></li>

<li><p>If <var>localName</var> is not <code data-x="attr-dialog-open">open</code>, then
return.</p></li>

<li><p>If <var>value</var> is null, <var>oldValue</var> is not null, and <var>element</var> is
<span>connected</span>, then run the <span>dialog cleanup steps</span> given
<var>element</var>.</p></li>

<li><p>If <var>value</var> is not null, <var>oldValue</var> is null, and <var>element</var> is
<span>connected</span>, then run the <span>dialog setup steps</span> given
<var>element</var>.</p></li>
</ol>

<p>To <dfn>show a modal dialog</dfn> given a <code>dialog</code> element <var>subject</var>:</p>
Expand Down Expand Up @@ -62458,13 +62473,6 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {

<li><p>Set <span>is modal</span> of <var>subject</var> to true.</p></li>

<li><p><span>Assert</span>: <var>subject</var>'s <span>node document</span>'s <span>open
dialogs list</span> does not <span data-x="list contains">contain</span>
<var>subject</var>.</p></li>

<li><p>Add <var>subject</var> to <var>subject</var>'s <span>node document</span>'s <span>open
dialogs list</span>.</p></li>

<li>
<p>Let <var>subject</var>'s <span>node document</span> be <span data-x="blocked by a modal
dialog">blocked by the modal dialog</span> <var>subject</var>.</p>
Expand All @@ -62481,8 +62489,6 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
already <span data-x="list contains">contain</span> <var>subject</var>, then <span>add an element
to the top layer</span> given <var>subject</var>.</p></li>

<li><p><span>Set the dialog close watcher</span> with <var>subject</var>.</p></li>

<li><p>Set <var>subject</var>'s <span>previously focused element</span> to the
<span>focused</span> element.</p></li>

Expand All @@ -62509,6 +62515,9 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
element <var>dialog</var>:</p>

<ol>
<li><p>If <span>dialog</span>'s <span data-x="dialog-close-watcher">close watcher</span> is not
null, then return.</p></li>

<li>
<p>Set <var>dialog</var>'s <span data-x="dialog-close-watcher">close watcher</span> to the
result of <span data-x="establish a close watcher">establishing a close watcher</span> given
Expand Down Expand Up @@ -62626,9 +62635,6 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {

<li><p>Set <span>is modal</span> of <var>subject</var> to false.</p></li>

<li><p><span data-x="list remove">Remove</span> <var>subject</var> from <var>subject</var>'s
<span>node document</span>'s <span>open dialogs list</span>.</p></li>

<li><p>If <var>result</var> is not null, then set the <code
data-x="dom-dialog-returnValue">returnValue</code> attribute to <var>result</var>.</p></li>

Expand All @@ -62654,19 +62660,6 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<li><p><span>Queue an element task</span> on the <span>user interaction task source</span> given the
<var>subject</var> element to <span data-x="concept-event-fire">fire an event</span> named
<code data-x="event-close">close</code> at <var>subject</var>.</p></li>

<li>
<p>If <var>subject</var>'s <span data-x="dialog-close-watcher">close watcher</span> is not null,
then:</p>

<ol>
<li><p><span data-x="close-watcher-destroy">Destroy</span> <var>subject</var>'s <span
data-x="dialog-close-watcher">close watcher</span>.</p></li>

<li><p>Set <var>subject</var>'s <span data-x="dialog-close-watcher">close watcher</span> to
null.</p></li>
</ol>
</li>
</ol>

</div>
Expand Down Expand Up @@ -62772,6 +62765,43 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
<li><p>Set <var>topDocument</var>'s <span>autofocus processed flag</span> to true.</p></li>
</ol>

<p>The <dfn>dialog setup steps</dfn>, given a <code>dialog</code> element <var>subject</var>, are
as follows:</p>

<ol>
<li><p><span>Assert</span>: <var>subject</var>'s <span>node document</span>'s <span>open dialogs
list</span> does not <span data-x="list contains">contain</span> <var>subject</var>.</p></li>

<li><p>Add <var>subject</var> to <var>subject</var>'s <span>node document</span>'s <span>open
dialogs list</span>.</p></li>

<li><p><span>Set the dialog close watcher</span> with <var>subject</var>.</p></li>
</ol>

<p>The <dfn>dialog cleanup steps</dfn>, given a <code>dialog</code> element <var>subject</var>,
are as follows:</p>

<ol>
<li><p><span>Assert</span>: <var>subject</var>'s <span>node document</span>'s <span>open dialogs
list</span> <span data-x="list contains">contains</span> <var>element</var>.</p></li>

<li><p><span data-x="list remove">Remove</span> <var>subject</var> from <var>subject</var>'s
<span>node document</span>'s <span>open dialogs list</span>.</p></li>

<li>
<p>If <var>subject</var>'s <span data-x="dialog-close-watcher">close watcher</span> is not null,
then:</p>

<ol>
<li><p><span data-x="close-watcher-destroy">Destroy</span> <var>subject</var>'s <span
data-x="dialog-close-watcher">close watcher</span>.</p></li>

<li><p>Set <var>subject</var>'s <span data-x="dialog-close-watcher">close watcher</span> to
null.</p></li>
</ol>
</li>
</ol>

<h4><dfn>Dialog light dismiss</dfn></h4>

<p class="note">"Light dismiss" means that clicking outside of a <code>dialog</code> element whose <code
Expand Down