Skip to content

Commit b294497

Browse files
authored
Specify default passive for document-level wheel/mousewheel/touchstart/touchmove events
Tests: web-platform-tests/wpt#34623 Fixes #365.
1 parent 8cd35b8 commit b294497

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

dom.bs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ dictionary EventListenerOptions {
951951
};
952952

953953
dictionary AddEventListenerOptions : EventListenerOptions {
954-
boolean passive = false;
954+
boolean passive;
955955
boolean once = false;
956956
AbortSignal signal;
957957
};
@@ -971,7 +971,7 @@ when something has occurred.
971971
<li><dfn for="event listener">type</dfn> (a string)
972972
<li><dfn for="event listener">callback</dfn> (null or an {{EventListener}} object)
973973
<li><dfn for="event listener">capture</dfn> (a boolean, initially false)
974-
<li><dfn for="event listener">passive</dfn> (a boolean, initially false)
974+
<li><dfn for="event listener">passive</dfn> (null or a boolean, initially null)
975975
<li><dfn for="event listener">once</dfn> (a boolean, initially false)
976976
<li><dfn for="event listener">signal</dfn> (null or an {{AbortSignal}} object)
977977
<li><dfn for="event listener">removed</dfn> (a boolean for bookkeeping purposes, initially false)
@@ -1069,16 +1069,18 @@ steps:
10691069
<ol>
10701070
<li><p>Let <var>capture</var> be the result of <a>flattening</a> <var>options</var>.
10711071

1072-
<li><p>Let <var>once</var> and <var>passive</var> be false.
1072+
<li><p>Let <var>once</var> be false.
10731073

1074-
<li><p>Let |signal| be null.
1074+
<li><p>Let |passive| and |signal| be null.
10751075

10761076
<li>
10771077
<p>If |options| is a <a for=/>dictionary</a>, then:
10781078

10791079
<ol>
1080-
<li><p>Set |passive| to |options|["{{AddEventListenerOptions/passive}}"] and |once| to
1081-
|options|["{{AddEventListenerOptions/once}}"].
1080+
<li><p>Set |once| to |options|["{{AddEventListenerOptions/once}}"].
1081+
1082+
<li><p>If |options|["{{AddEventListenerOptions/passive}}"] [=map/exists=], then set |passive| to
1083+
|options|["{{AddEventListenerOptions/passive}}"].
10821084

10831085
<li><p>If |options|["{{AddEventListenerOptions/signal}}"] [=map/exists=], then set |signal| to
10841086
|options|["{{AddEventListenerOptions/signal}}"].
@@ -1098,6 +1100,26 @@ constructor steps are to do nothing.
10981100
if this would be useful for your programs. For now, all author-created {{EventTarget}}s do not
10991101
participate in a tree structure.</p>
11001102

1103+
<p>The <dfn>default passive value</dfn>, given an event type |type| and an {{EventTarget}}
1104+
|eventTarget|, is determined as follows:
1105+
1106+
<ol>
1107+
<li>
1108+
<p>Return true if all of the following are true:
1109+
1110+
<ul>
1111+
<li><p>|type| is one of "<code>touchstart</code>", "<code>touchmove</code>",
1112+
"<code>wheel</code>", or "<code>mousewheel</code>". [[TOUCH-EVENTS]] [[UIEVENTS]]
1113+
1114+
<li><p>|eventTarget| is a {{Window}} object, or is a <a for=/>node</a> whose <a>node document</a>
1115+
is |eventTarget|, or is a <a for=/>node</a> whose <a>node document</a>'s <a>document element</a>
1116+
is |eventTarget|, or is a <a for=/>node</a> whose <a>node document</a>'s
1117+
<a lt="the body element">body element</a> is |eventTarget|. [[!HTML]]
1118+
</ul>
1119+
1120+
<li><p>Return false.
1121+
</ol>
1122+
11011123
<p>To <dfn export>add an event listener</dfn>, given an {{EventTarget}} object
11021124
<var>eventTarget</var> and an <a>event listener</a> <var>listener</var>, run these steps:
11031125

@@ -1115,6 +1137,9 @@ participate in a tree structure.</p>
11151137

11161138
<li><p>If <var>listener</var>'s <a for="event listener">callback</a> is null, then return.
11171139

1140+
<li><p>If <var>listener</var>'s <a for="event listener">passive</a> is null, then set it to the
1141+
<a>default passive value</a> given |type| and |eventTarget|.
1142+
11181143
<li><p>If <var>eventTarget</var>'s <a>event listener list</a> does not <a for=list>contain</a> an
11191144
<a>event listener</a> whose <a for="event listener">type</a> is <var>listener</var>'s
11201145
<a for="event listener">type</a>, <a for="event listener">callback</a> is <var>listener</var>'s

0 commit comments

Comments
 (0)