Skip to content

Commit 03357df

Browse files
authored
Editorial: mark up algorithms about Events
Also fix a typo that Bikeshed was able to find thanks to this.
1 parent 277983d commit 03357df

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

dom.bs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ string.
510510
<p>The <dfn attribute for=Event><code>currentTarget</code></dfn> attribute must return the value it
511511
was initialized to. When an <a>event</a> is created the attribute must be initialized to null.
512512

513+
<div algorithm>
513514
<p>The <dfn method for=Event><code>composedPath()</code></dfn> method steps are:
514515

515516
<ol>
@@ -608,6 +609,7 @@ was initialized to. When an <a>event</a> is created the attribute must be initia
608609

609610
<li><p>Return <var>composedPath</var>.
610611
</ol>
612+
</div>
611613

612614
<p>The <dfn attribute for=Event><code>eventPhase</code></dfn> attribute must return the value it was
613615
initialized to, which must be one of the following:
@@ -703,6 +705,7 @@ initialized to.
703705

704706
<hr>
705707

708+
<div algorithm>
706709
<p>To <dfn export for=Event id=concept-event-initialize>initialize</dfn> an <var>event</var>, with
707710
<var>type</var>, <var>bubbles</var>, and <var>cancelable</var>, run these steps:
708711

@@ -722,7 +725,9 @@ initialized to.
722725

723726
<li><p>Set <var>event</var>'s {{Event/cancelable}} attribute to <var>cancelable</var>.
724727
</ol>
728+
</div>
725729

730+
<div algorithm>
726731
<p>The
727732
<dfn method for=Event><code>initEvent(<var>type</var>, <var>bubbles</var>, <var>cancelable</var>)</code></dfn>
728733
method steps are:
@@ -733,6 +738,7 @@ method steps are:
733738
<li><p><a>Initialize</a> <a>this</a> with <var>type</var>, <var>bubbles</var>, and
734739
<var>cancelable</var>.
735740
</ol>
741+
</div>
736742

737743
<p class=note>{{Event/initEvent()}} is redundant with <a>event</a> constructors and
738744
incapable of setting {{Event/composed}}. It has to be supported for legacy content.
@@ -792,6 +798,7 @@ dictionary CustomEventInit : EventInit {
792798
<p>The <dfn attribute for=CustomEvent><code>detail</code></dfn> attribute must return the value it
793799
was initialized to.
794800

801+
<div algorithm>
795802
<p>The
796803
<dfn method for=CustomEvent><code>initCustomEvent(<var>type</var>, <var>bubbles</var>, <var>cancelable</var>, <var>detail</var>)</code></dfn>
797804
method steps are:
@@ -804,6 +811,7 @@ method steps are:
804811

805812
<li><p>Set <a>this</a>'s {{CustomEvent/detail}} attribute to <var>detail</var>.
806813
</ol>
814+
</div>
807815

808816

809817
<h3 id=constructing-events>Constructing events</h3>
@@ -816,6 +824,7 @@ method steps are:
816824
<p class=note>This construct can be used by {{Event}} subclasses that have a more complex structure
817825
than a simple 1:1 mapping between their initializing dictionary members and IDL attributes.
818826

827+
<div algorithm>
819828
<p>When a <dfn export for=Event id=concept-event-constructor>constructor</dfn> of the {{Event}}
820829
interface, or of an interface that inherits from the {{Event}} interface, is invoked, these steps
821830
must be run, given the arguments <var>type</var> and <var>eventInitDict</var>:
@@ -828,7 +837,9 @@ must be run, given the arguments <var>type</var> and <var>eventInitDict</var>:
828837

829838
<li><p>Return <var>event</var>.
830839
</ol>
840+
</div>
831841

842+
<div algorithm>
832843
<p>To
833844
<dfn export id=concept-event-create lt="creating an event|create an event">create an event</dfn>
834845
using <var>eventInterface</var>, which must be either {{Event}} or an interface that inherits from
@@ -858,13 +869,15 @@ it, and optionally given a <a>realm</a> <var>realm</var>, run these steps:</p>
858869

859870
<li><p>Return <var>event</var>.
860871
</ol>
872+
</div>
861873

862874
<p class=note><a>Create an event</a> is meant to be used by other specifications which need to
863875
separately <a lt="create an event">create</a> and <a>dispatch</a> events, instead of simply
864876
<a lt="fire an event">firing</a> them. It ensures the event's attributes are initialized to the
865877
correct defaults.</p>
866878

867-
<p>The <dfn noexport>inner event creation steps</dfn>, given an <var>interface</var>,
879+
<div algorithm>
880+
<p>The <dfn noexport>inner event creation steps</dfn>, given an <var>eventInterface</var>,
868881
<var>realm</var>, <var>time</var>, and <var>dictionary</var>, are as follows:</p>
869882

870883
<ol>
@@ -890,6 +903,7 @@ correct defaults.</p>
890903

891904
<li><p>Return <var>event</var>.
892905
</ol>
906+
</div>
893907

894908

895909
<h3 id=defining-event-interfaces>Defining event interfaces</h3>
@@ -1246,6 +1260,7 @@ property of the event being dispatched.
12461260
<p>Ideally, any new event APIs are defined such that they do not need this property. (Use
12471261
<a href="https://github.com/whatwg/dom/issues">whatwg/dom</a> for discussion.)
12481262

1263+
<div algorithm>
12491264
<p>To <dfn export>legacy-obtain service worker fetch event listener callbacks</dfn> given a
12501265
{{ServiceWorkerGlobalScope}} <var>global</var>, run these steps. They return a <a for=/>list</a> of
12511266
{{EventListener}} objects.
@@ -1265,10 +1280,12 @@ property of the event being dispatched.
12651280

12661281
<li><p>Return <var>callbacks</var>.
12671282
</ol>
1283+
</div>
12681284

12691285

12701286
<h3 id=dispatching-events>Dispatching events</h3>
12711287

1288+
<div algorithm>
12721289
<p>To <dfn export id=concept-event-dispatch>dispatch</dfn> an <var>event</var> to a
12731290
<var>target</var>, with an optional <var>legacy target override flag</var> and an optional
12741291
<var>legacyOutputDidListenersThrowFlag</var>, run these steps:
@@ -1468,7 +1485,9 @@ property of the event being dispatched.
14681485

14691486
<li><p>Return false if <var>event</var>'s <a>canceled flag</a> is set; otherwise true.
14701487
</ol>
1488+
</div>
14711489

1490+
<div algorithm>
14721491
<p>To <dfn noexport id=concept-event-path-append>append to an event path</dfn>, given an
14731492
<var>event</var>, <var>invocationTarget</var>, <var>shadowAdjustedTarget</var>,
14741493
<var>relatedTarget</var>, <var>touchTargets</var>, and a <var>slot-in-closed-tree</var>, run these
@@ -1494,7 +1513,9 @@ steps:</p>
14941513
<a for=Event/path>root-of-closed-tree</a> is <var>root-of-closed-tree</var>, and
14951514
<a for=Event/path>slot-in-closed-tree</a> is <var>slot-in-closed-tree</var>.
14961515
</ol>
1516+
</div>
14971517

1518+
<div algorithm>
14981519
<p>To <dfn noexport id=concept-event-listener-invoke>invoke</dfn>, given a <var>struct</var>,
14991520
<var>event</var>, <var>phase</var>, and an optional <var>legacyOutputDidListenersThrowFlag</var>,
15001521
run these steps:
@@ -1559,7 +1580,9 @@ run these steps:
15591580
<li><p>Set <var>event</var>'s {{Event/type}} attribute value to <var>originalEventType</var>.
15601581
</ol>
15611582
</ol>
1583+
</div>
15621584

1585+
<div algorithm>
15631586
<p>To <dfn noexport id=concept-event-listener-inner-invoke>inner invoke</dfn>, given an
15641587
<var>event</var>, <var>listeners</var>, <var>phase</var>, <var>invocationTargetInShadowTree</var>,
15651588
and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:
@@ -1633,10 +1656,12 @@ and an optional <var>legacyOutputDidListenersThrowFlag</var>, run these steps:
16331656

16341657
<li><p>Return <var>found</var>.
16351658
</ol>
1659+
</div>
16361660

16371661

16381662
<h3 id=firing-events>Firing events</h3>
16391663

1664+
<div algorithm>
16401665
<p>To <dfn export id=concept-event-fire>fire an event</dfn> named <var>e</var> at <var>target</var>,
16411666
optionally using an <var>eventConstructor</var>, with a description of how IDL attributes are to be
16421667
initialized, and a <var>legacy target override flag</var>, run these steps:
@@ -1659,6 +1684,7 @@ initialized, and a <var>legacy target override flag</var>, run these steps:
16591684
<li><p>Return the result of <a>dispatching</a> <var>event</var> at <var>target</var>, with
16601685
<var>legacy target override flag</var> set if set.
16611686
</ol>
1687+
</div>
16621688

16631689
<p class=note>Fire in the context of DOM is short for
16641690
<a lt="create an event">creating</a>, initializing, and <a>dispatching</a> an <a>event</a>.

0 commit comments

Comments
 (0)