Skip to content

Commit a13a3c7

Browse files
RByersannevk
authored andcommitted
Remove passive as event listener key
This changes makes passive no longer contribute to the uniqueness of an event listener. It therefore also no longer needs to be supported as part of removeEventListener(). Fixes WICG/EventListenerOptions#27. PR: #236
1 parent fdad8cb commit a13a3c7

File tree

2 files changed

+42
-45
lines changed

2 files changed

+42
-45
lines changed

dom.bs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ inherits from the {{Event}} interface.
694694

695695
<dt><code><var>event</var> . <a method for=Event lt="preventDefault()">preventDefault</a>()</code>
696696
<dd>If invoked when the {{Event/cancelable}} attribute value is true, and while executing a
697-
listener for the <var>event</var> with {{EventListenerOptions/passive}} set to false, signals to
697+
listener for the <var>event</var> with {{AddEventListenerOptions/passive}} set to false, signals to
698698
the operation that caused <var>event</var> to be <a>dispatched</a> that it needs to be canceled.
699699

700700
<dt><code><var>event</var> . {{Event/defaultPrevented}}</code>
@@ -949,10 +949,10 @@ callback interface EventListener {
949949

950950
dictionary EventListenerOptions {
951951
boolean capture;
952-
boolean passive;
953952
};
954953

955954
dictionary AddEventListenerOptions : EventListenerOptions {
955+
boolean passive;
956956
boolean once;
957957
};
958958
</pre>
@@ -1012,8 +1012,8 @@ specified otherwise it returns null.
10121012
will only be invoked once after which the event listener will be removed.
10131013

10141014
The <a>event listener</a> is appended to <var>target</var>'s list of <a>event listeners</a> and is
1015-
not appended if it is a duplicate, i.e., having the same <b>type</b>, <b>callback</b>,
1016-
<b>capture</b> and <b>passive</b> values.
1015+
not appended if it is a duplicate, i.e., having the same <b>type</b>, <b>callback</b>, and
1016+
<b>capture</b> values.
10171017

10181018
<dt><code><var>target</var> . <a method lt="removeEventListener()">removeEventListener</a>(<var>type</var>, <var>callback</var> [, <var>options</var>])</code>
10191019
<dd>Remove the <a>event listener</a>
@@ -1032,27 +1032,26 @@ specified otherwise it returns null.
10321032
steps:
10331033

10341034
<ol>
1035-
<li><p>Let <var>capture</var> and <var>passive</var> be false.
1035+
<li><p>Let <var>capture</var> be false.
10361036

10371037
<li><p>If <var>options</var> is a boolean, set <var>capture</var> to <var>options</var>.
10381038

10391039
<li><p>If <var>options</var> is a dictionary and <code>{{EventListenerOptions/capture}}</code> is
10401040
present in <var>options</var> with value true, then set <var>capture</var> to true.
10411041

1042-
<li><p>If <var>options</var> is a dictionary and <code>{{EventListenerOptions/passive}}</code> is
1043-
present in <var>options</var> with value true, then set <var>passive</var> to true.
1044-
1045-
<li><p>Return <var>capture</var> and <var>passive</var>.
1042+
<li><p>Return <var>capture</var>.
10461043
</ol>
10471044

10481045
<p>To <dfn export for=Event>flatten more</dfn><!-- sorry --> <var>options</var>, run these
10491046
steps:
10501047

10511048
<ol>
1052-
<li><p>Let <var>capture</var> and <var>passive</var> be the result of <a>flattening</a>
1053-
<var>options</var>.
1049+
<li><p>Let <var>capture</var> be the result of <a>flattening</a> <var>options</var>.
10541050

1055-
<li><p>Let <var>once</var> be false.
1051+
<li><p>Let <var>once</var> and <var>passive</var> be false.
1052+
1053+
<li><p>If <var>options</var> is a dictionary and <code>{{AddEventListenerOptions/passive}}</code>
1054+
is present in <var>options</var> with value true, then set <var>passive</var> to true.
10561055

10571056
<li><p>If <var>options</var> is a dictionary and <code>{{AddEventListenerOptions/once}}</code> is
10581057
present in <var>options</var> with value true, then set <var>once</var> to true.
@@ -1081,10 +1080,9 @@ method, when invoked, must run these steps:
10811080

10821081
<li><p>If <a>context object</a>'s associated list of <a>event listener</a> does not contain an
10831082
<a>event listener</a> whose <b>type</b> is <var>type</var>, <b>callback</b> is <var>callback</var>,
1084-
<b>capture</b> is <var>capture</var>, and <b>passive</b> is <var>passive</var>, then append a new
1085-
<a>event listener</a> to it, whose <b>type</b> is <var>type</var>, <b>callback</b> is
1086-
<var>callback</var>, <b>capture</b> is <var>capture</var>, <b>passive</b> is <var>passive</var>,
1087-
and <b>once</b> is <var>once</var>.
1083+
and <b>capture</b> is <var>capture</var>, then append a new <a>event listener</a> to it, whose
1084+
<b>type</b> is <var>type</var>, <b>callback</b> is <var>callback</var>, <b>capture</b> is
1085+
<var>capture</var>, <b>passive</b> is <var>passive</var>, and <b>once</b> is <var>once</var>.
10881086
</ol>
10891087

10901088
<p>The
@@ -1096,13 +1094,12 @@ method, when invoked, must, run these steps
10961094
its associated <a>service worker</a>'s <a>script resource</a>'s <a>has ever been evaluated flag</a>
10971095
is set, <a>throw</a> a <code>TypeError</code>. [[!SERVICE-WORKERS]]
10981096

1099-
<li><p>Let <var>capture</var> and <var>passive</var> be the result of <a>flattening</a>
1100-
<var>options</var>.
1097+
<li><p>Let <var>capture</var> be the result of <a>flattening</a> <var>options</var>.
11011098

11021099
<li><p>If there is an <a>event listener</a> in the associated list of <a>event listeners</a> whose
1103-
<b>type</b> is <var>type</var>, <b>callback</b> is <var>callback</var>, <b>capture</b> is
1104-
<var>capture</var>, and <b>passive</b> is <var>passive</var> then set that <a>event listener</a>'s
1105-
<b>removed</b> to true and remove it from the associated list of <a>event listeners</a>.
1100+
<b>type</b> is <var>type</var>, <b>callback</b> is <var>callback</var>, and <b>capture</b> is
1101+
<var>capture</var>, then set that <a>event listener</a>'s <b>removed</b> to true and remove it from
1102+
the associated list of <a>event listeners</a>.
11061103
</ol>
11071104

11081105
<p>The <dfn method for=EventTarget><code>dispatchEvent(<var>event</var>)</code></dfn> method, when
@@ -1129,12 +1126,12 @@ requires observing <a>event listeners</a>. This can make the presence of listene
11291126
that even empty listeners can have a dramatic performance impact on the behavior of the application.
11301127
For example, touch and wheel events which can be used to block asynchronous scrolling. In some cases
11311128
this problem can be mitigated by specifying the event to be {{Event/cancelable}} only when there is
1132-
at least one non-{{EventListenerOptions/passive}} listener. For example,
1133-
non-{{EventListenerOptions/passive}} {{TouchEvent}} listeners must block scrolling, but if all
1134-
listeners are {{EventListenerOptions/passive}} then scrolling can be allowed to start
1129+
at least one non-{{AddEventListenerOptions/passive}} listener. For example,
1130+
non-{{AddEventListenerOptions/passive}} {{TouchEvent}} listeners must block scrolling, but if all
1131+
listeners are {{AddEventListenerOptions/passive}} then scrolling can be allowed to start
11351132
<a>in parallel</a> by making the {{TouchEvent}} uncancelable (so that calls to
11361133
{{Event/preventDefault()}} are ignored). So code dispatching an event is able to observe the absence
1137-
of non-{{EventListenerOptions/passive}} listeners, and use that to clear the {{Event/cancelable}}
1134+
of non-{{AddEventListenerOptions/passive}} listeners, and use that to clear the {{Event/cancelable}}
11381135
property of the event being dispatched.
11391136

11401137
<p>Ideally, any new event APIs are defined such that they do not need this property (use

0 commit comments

Comments
 (0)