Skip to content

Commit 451dae2

Browse files
authored
Correct undefined variable in add/remove an event listener
Also add <div algorithm> wrappers to make this problem less likely to reoccur in this section. Fixes #1203.
1 parent 8602242 commit 451dae2

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

dom.bs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ are not to be used for anything else. [[!HTML]]
10291029
{{Event/preventDefault()}} method was not invoked; otherwise false.
10301030
</dl>
10311031

1032+
<div algorithm>
10321033
<p>To <dfn export for=Event id=concept-flatten-options>flatten</dfn> <var>options</var>, run these
10331034
steps:
10341035

@@ -1037,7 +1038,9 @@ steps:
10371038

10381039
<li><p>Return |options|["{{EventListenerOptions/capture}}"].
10391040
</ol>
1041+
</div>
10401042

1043+
<div algorithm>
10411044
<p>To <dfn export for=Event>flatten more</dfn><!-- sorry --> <var>options</var>, run these
10421045
steps:
10431046

@@ -1063,6 +1066,7 @@ steps:
10631066

10641067
<li><p>Return <var>capture</var>, <var>passive</var>, <var>once</var>, and <var>signal</var>.
10651068
</ol>
1069+
</div>
10661070

10671071
<p>The <dfn constructor for=EventTarget lt=EventTarget()><code>new EventTarget()</code></dfn>
10681072
constructor steps are to do nothing.
@@ -1076,6 +1080,7 @@ or <a for=EventTarget>legacy-canceled-activation behavior</a>.
10761080
if this would be useful for your programs. For now, all author-created {{EventTarget}}s do not
10771081
participate in a tree structure.</p>
10781082

1083+
<div algorithm>
10791084
<p>The <dfn>default passive value</dfn>, given an event type |type| and an {{EventTarget}}
10801085
|eventTarget|, is determined as follows:
10811086

@@ -1095,7 +1100,9 @@ participate in a tree structure.</p>
10951100

10961101
<li><p>Return false.
10971102
</ol>
1103+
</div>
10981104

1105+
<div algorithm>
10991106
<p>To <dfn export>add an event listener</dfn>, given an {{EventTarget}} object
11001107
<var>eventTarget</var> and an <a>event listener</a> <var>listener</var>, run these steps:
11011108

@@ -1114,7 +1121,8 @@ participate in a tree structure.</p>
11141121
<li><p>If <var>listener</var>'s <a for="event listener">callback</a> is null, then return.
11151122

11161123
<li><p>If <var>listener</var>'s <a for="event listener">passive</a> is null, then set it to the
1117-
<a>default passive value</a> given |type| and |eventTarget|.
1124+
<a>default passive value</a> given <var>listener</var>'s <a for="event listener">type</a> and
1125+
<var>eventTarget</var>.
11181126

11191127
<li><p>If <var>eventTarget</var>'s <a>event listener list</a> does not <a for=list>contain</a> an
11201128
<a>event listener</a> whose <a for="event listener">type</a> is <var>listener</var>'s
@@ -1134,7 +1142,9 @@ participate in a tree structure.</p>
11341142

11351143
<p class=note>The <a>add an event listener</a> concept exists to ensure <a>event handlers</a> use
11361144
the same code path. [[HTML]]
1145+
</div>
11371146

1147+
<div algorithm>
11381148
<p>The
11391149
<dfn method for=EventTarget><code>addEventListener(<var>type</var>, <var>callback</var>, <var>options</var>)</code></dfn>
11401150
method steps are:
@@ -1149,31 +1159,37 @@ method steps are:
11491159
<a for="event listener">passive</a> is <var>passive</var>, <a for="event listener">once</a> is
11501160
<var>once</var>, and <a for="event listener">signal</a> is <var>signal</var>.
11511161
</ol>
1162+
</div>
11521163

1164+
<div algorithm>
11531165
<p>To <dfn export>remove an event listener</dfn>, given an {{EventTarget}} object
11541166
<var>eventTarget</var> and an <a>event listener</a> <var>listener</var>, run these steps:
11551167

11561168
<ol>
11571169
<li><p>If <var>eventTarget</var> is a {{ServiceWorkerGlobalScope}} object and its
11581170
<a for="ServiceWorkerGlobalScope">service worker</a>'s
1159-
<a for="service worker">set of event types to handle</a> contains <var>type</var>, then
1160-
<a>report a warning to the console</a> that this might not give the expected results.
1161-
[[!SERVICE-WORKERS]]
1171+
<a for="service worker">set of event types to handle</a> <a for=set>contains</a>
1172+
<var>listener</var>'s <a for="event listener">type</a>, then <a>report a warning to the console</a>
1173+
that this might not give the expected results. [[!SERVICE-WORKERS]]
11621174

11631175
<li><p>Set <var>listener</var>'s <a for="event listener">removed</a> to true and
11641176
<a for=list>remove</a> <var>listener</var> from <var>eventTarget</var>'s
11651177
<a for=EventTarget>event listener list</a>.
11661178
</ol>
11671179

11681180
<p class=note>HTML needs this to define event handlers. [[HTML]]
1181+
</div>
11691182

1183+
<div algorithm>
11701184
<p>To <dfn export>remove all event listeners</dfn>, given an {{EventTarget}} object
11711185
<var>eventTarget</var>, <a for=list>for each</a> <var>listener</var> of <var>eventTarget</var>'s
11721186
<a for=EventTarget>event listener list</a>, <a>remove an event listener</a> with
11731187
<var>eventTarget</var> and <var>listener</var>.
11741188

11751189
<p class=note>HTML needs this to define <code>document.open()</code>. [[HTML]]
1190+
</div>
11761191

1192+
<div algorithm>
11771193
<p>The
11781194
<dfn method for=EventTarget><code>removeEventListener(<var>type</var>, <var>callback</var>, <var>options</var>)</code></dfn>
11791195
method steps are:
@@ -1191,7 +1207,9 @@ method steps are:
11911207
<p class=note>The event listener list will not contain multiple event listeners with equal
11921208
<var>type</var>, <var>callback</var>, and <var>capture</var>, as <a>add an event listener</a>
11931209
prevents that.
1210+
</div>
11941211

1212+
<div algorithm>
11951213
<p>The <dfn method for=EventTarget><code>dispatchEvent(<var>event</var>)</code></dfn> method steps
11961214
are:
11971215

@@ -1203,6 +1221,7 @@ are:
12031221

12041222
<li><p>Return the result of <a>dispatching</a> <var>event</var> to <a>this</a>.
12051223
</ol>
1224+
</div>
12061225

12071226

12081227
<h3 id=observing-event-listeners>Observing event listeners</h3>
@@ -10165,6 +10184,7 @@ James M Snell,
1016510184
James Robinson,
1016610185
Jeffrey Yasskin,
1016710186
Jens Lindström,
10187+
Jeremy Davis<!-- jeremydavis519; GitHub -->,
1016810188
Jesse McCarthy,
1016910189
Jinho Bang,
1017010190
João Eiras,

0 commit comments

Comments
 (0)