Skip to content

Commit be8e547

Browse files
keithamuslozy219
authored andcommitted
Editorial: extract "show a modal dialog" algorithm
This will help with whatwg#9841.
1 parent 9da854d commit be8e547

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

source

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61962,22 +61962,25 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6196261962
</ol>
6196361963

6196461964
<p>The <dfn method for="HTMLDialogElement"><code
61965-
data-x="dom-dialog-showModal">showModal()</code></dfn> method steps are:</p>
61965+
data-x="dom-dialog-showModal">showModal()</code></dfn> method steps are to <span>show a modal
61966+
dialog</span> given <span>this</span>.</p>
61967+
61968+
<p>To <dfn>show a modal dialog</dfn> given a <code>dialog</code> element <var>subject</var>:</p>
6196661969

6196761970
<ol>
61968-
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute and
61969-
<span>is modal</span> of <span>this</span> is true, then return.</p></li>
61971+
<li><p>If <var>subject</var> has an <code data-x="attr-dialog-open">open</code> attribute and
61972+
<span>is modal</span> of <var>subject</var> is true, then return.</p></li>
6197061973

61971-
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute, then
61974+
<li><p>If <var>subject</var> has an <code data-x="attr-dialog-open">open</code> attribute, then
6197261975
throw an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>
6197361976

61974-
<li><p>If <span>this</span>'s <span>node document</span> is not <span>fully active</span>, then
61977+
<li><p>If <var>subject</var>'s <span>node document</span> is not <span>fully active</span>, then
6197561978
throw an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>
6197661979

61977-
<li><p>If <span>this</span> is not <span>connected</span>, then throw an
61980+
<li><p>If <var>subject</var> is not <span>connected</span>, then throw an
6197861981
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>
6197961982

61980-
<li><p>If <span>this</span> is in the <span data-x="popover-showing-state">popover showing
61983+
<li><p>If <var>subject</var> is in the <span data-x="popover-showing-state">popover showing
6198161984
state</span>, then throw an <span>"<code>InvalidStateError</code>"</span>
6198261985
<code>DOMException</code>.</p></li>
6198361986

@@ -61986,35 +61989,35 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6198661989
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, the <code
6198761990
data-x="dom-ToggleEvent-oldState">oldState</code> attribute initialized to "<code
6198861991
data-x="">closed</code>", and the <code data-x="dom-ToggleEvent-newState">newState</code>
61989-
attribute initialized to "<code data-x="">open</code>" at <span>this</span> is false, then
61992+
attribute initialized to "<code data-x="">open</code>" at <var>subject</var> is false, then
6199061993
return.</p></li>
6199161994

61992-
<li><p>If <span>this</span> has an <code data-x="attr-dialog-open">open</code> attribute,
61995+
<li><p>If <var>subject</var> has an <code data-x="attr-dialog-open">open</code> attribute,
6199361996
then return.</p></li>
6199461997

61995-
<li><p>If <span>this</span> is not <span>connected</span>, then return.</p></li>
61998+
<li><p>If <var>subject</var> is not <span>connected</span>, then return.</p></li>
6199661999

61997-
<li><p>If <span>this</span> is in the <span data-x="popover-showing-state">popover showing
62000+
<li><p>If <var>subject</var> is in the <span data-x="popover-showing-state">popover showing
6199862001
state</span>, then return.</p></li>
6199962002

6200062003
<li><p><span>Queue a dialog toggle event task</span> given <var>subject</var>, "<code
6200162004
data-x="">closed</code>", and "<code data-x="">open</code>".</p></li>
6200262005

62003-
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to <span>this</span>, whose
62006+
<li><p>Add an <code data-x="attr-dialog-open">open</code> attribute to <var>subject</var>, whose
6200462007
value is the empty string.</p></li>
6200562008

62006-
<li><p>Set <span>is modal</span> of <span>this</span> to true.</p></li>
62009+
<li><p>Set <span>is modal</span> of <var>subject</var> to true.</p></li>
6200762010

62008-
<li><p><span>Assert</span>: <span>this</span>'s <span>node document</span>'s <span>open
62011+
<li><p><span>Assert</span>: <var>subject</var>'s <span>node document</span>'s <span>open
6200962012
dialogs list</span> does not <span data-x="list contains">contain</span>
62010-
<span>this</span>.</p></li>
62013+
<var>subject</var>.</p></li>
6201162014

62012-
<li><p>Add <span>this</span> to <span>this</span>'s <span>node document</span>'s <span>open
62015+
<li><p>Add <var>subject</var> to <var>subject</var>'s <span>node document</span>'s <span>open
6201362016
dialogs list</span>.</p></li>
6201462017

6201562018
<li>
62016-
<p>Let <span>this</span>'s <span>node document</span> be <span data-x="blocked by a modal
62017-
dialog">blocked by the modal dialog</span> <span>this</span>.</p>
62019+
<p>Let <var>subject</var>'s <span>node document</span> be <span data-x="blocked by a modal
62020+
dialog">blocked by the modal dialog</span> <var>subject</var>.</p>
6201862021

6201962022
<p class="note" id="note-dialog-plus-focus-fixup">This will cause the <span>focused area of the
6202062023
document</span> to become <span>inert</span> (unless that currently focused area is a
@@ -62024,23 +62027,23 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6202462027
focus.</p>
6202562028
</li>
6202662029

62027-
<li><p>If <span>this</span>'s <span>node document</span>'s <span>top layer</span> does not
62028-
already <span data-x="list contains">contain</span> <span>this</span>, then <span>add an element
62029-
to the top layer</span> given <span>this</span>.</p></li>
62030+
<li><p>If <var>subject</var>'s <span>node document</span>'s <span>top layer</span> does not
62031+
already <span data-x="list contains">contain</span> <var>subject</var>, then <span>add an element
62032+
to the top layer</span> given <var>subject</var>.</p></li>
6203062033

62031-
<li><p><span>Set the dialog close watcher</span> with <span>this</span>.</p></li>
62034+
<li><p><span>Set the dialog close watcher</span> with <var>subject</var>.</p></li>
6203262035

62033-
<li><p>Set <span>this</span>'s <span>previously focused element</span> to the
62036+
<li><p>Set <var>subject</var>'s <span>previously focused element</span> to the
6203462037
<span>focused</span> element.</p></li>
6203562038

62036-
<li><p>Let <var>document</var> be <span>this</span>'s <span>node document</span>.</p></li>
62039+
<li><p>Let <var>document</var> be <var>subject</var>'s <span>node document</span>.</p></li>
6203762040

6203862041
<li><p>Let <var>hideUntil</var> be the result of running <span>topmost popover ancestor</span>
62039-
given <span>this</span>, <var>document</var>'s <span>showing hint popover list</span>, null, and
62042+
given <var>subject</var>, <var>document</var>'s <span>showing hint popover list</span>, null, and
6204062043
false.</p></li>
6204162044

6204262045
<li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to the result of running
62043-
<span>topmost popover ancestor</span> given <span>this</span>, <var>document</var>'s
62046+
<span>topmost popover ancestor</span> given <var>subject</var>, <var>document</var>'s
6204462047
<span>showing auto popover list</span>, null, and false.</p></li>
6204562048

6204662049
<li><p>If <var>hideUntil</var> is null, then set <var>hideUntil</var> to
@@ -62049,7 +62052,7 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6204962052
<li><p>Run <span data-x="hide-all-popovers-until">hide all popovers until</span> given
6205062053
<var>hideUntil</var>, false, and true.</p></li>
6205162054

62052-
<li><p>Run the <span>dialog focusing steps</span> given <span>this</span>.</p></li>
62055+
<li><p>Run the <span>dialog focusing steps</span> given <var>subject</var>.</p></li>
6205362056
</ol>
6205462057

6205562058
<p id="canceling-dialogs">To <dfn>set the dialog close watcher</dfn>, given a <code>dialog</code>
@@ -62063,9 +62066,10 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
6206362066

6206462067
<ul>
6206562068
<li><p><i data-x="create-close-watcher-cancelAction">cancelAction</i> given
62066-
<var>canPreventClose</var> being to return the result of <span data-x="concept-event-fire">firing
62067-
an event</span> named <code data-x="event-cancel">cancel</code> at <var>dialog</var>, with the
62068-
<code data-x="dom-Event-cancelable">cancelable</code> attribute initialized to
62069+
<var>canPreventClose</var> being to return the result of <span
62070+
data-x="concept-event-fire">firing an event</span> named <code
62071+
data-x="event-cancel">cancel</code> at <var>dialog</var>, with the <code
62072+
data-x="dom-Event-cancelable">cancelable</code> attribute initialized to
6206962073
<var>canPreventClose</var>.</p></li>
6207062074

6207162075
<li><p><i data-x="create-close-watcher-closeAction">closeAction</i> being to <span>close the

0 commit comments

Comments
 (0)