Skip to content

Commit

Permalink
Specify default passive for document-level wheel/mousewheel/touchstar…
Browse files Browse the repository at this point in the history
…t/touchmove events

Tests: web-platform-tests/wpt#34623

Fixes #365.
  • Loading branch information
zcorpan authored Jun 30, 2022
1 parent 8cd35b8 commit b294497
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ dictionary EventListenerOptions {
};

dictionary AddEventListenerOptions : EventListenerOptions {
boolean passive = false;
boolean passive;
boolean once = false;
AbortSignal signal;
};
Expand All @@ -971,7 +971,7 @@ when something has occurred.
<li><dfn for="event listener">type</dfn> (a string)
<li><dfn for="event listener">callback</dfn> (null or an {{EventListener}} object)
<li><dfn for="event listener">capture</dfn> (a boolean, initially false)
<li><dfn for="event listener">passive</dfn> (a boolean, initially false)
<li><dfn for="event listener">passive</dfn> (null or a boolean, initially null)
<li><dfn for="event listener">once</dfn> (a boolean, initially false)
<li><dfn for="event listener">signal</dfn> (null or an {{AbortSignal}} object)
<li><dfn for="event listener">removed</dfn> (a boolean for bookkeeping purposes, initially false)
Expand Down Expand Up @@ -1069,16 +1069,18 @@ steps:
<ol>
<li><p>Let <var>capture</var> be the result of <a>flattening</a> <var>options</var>.

<li><p>Let <var>once</var> and <var>passive</var> be false.
<li><p>Let <var>once</var> be false.

<li><p>Let |signal| be null.
<li><p>Let |passive| and |signal| be null.

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

<ol>
<li><p>Set |passive| to |options|["{{AddEventListenerOptions/passive}}"] and |once| to
|options|["{{AddEventListenerOptions/once}}"].
<li><p>Set |once| to |options|["{{AddEventListenerOptions/once}}"].

<li><p>If |options|["{{AddEventListenerOptions/passive}}"] [=map/exists=], then set |passive| to
|options|["{{AddEventListenerOptions/passive}}"].

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

<p>The <dfn>default passive value</dfn>, given an event type |type| and an {{EventTarget}}
|eventTarget|, is determined as follows:

<ol>
<li>
<p>Return true if all of the following are true:

<ul>
<li><p>|type| is one of "<code>touchstart</code>", "<code>touchmove</code>",
"<code>wheel</code>", or "<code>mousewheel</code>". [[TOUCH-EVENTS]] [[UIEVENTS]]

<li><p>|eventTarget| is a {{Window}} object, or is a <a for=/>node</a> whose <a>node document</a>
is |eventTarget|, or is a <a for=/>node</a> whose <a>node document</a>'s <a>document element</a>
is |eventTarget|, or is a <a for=/>node</a> whose <a>node document</a>'s
<a lt="the body element">body element</a> is |eventTarget|. [[!HTML]]
</ul>

<li><p>Return false.
</ol>

<p>To <dfn export>add an event listener</dfn>, given an {{EventTarget}} object
<var>eventTarget</var> and an <a>event listener</a> <var>listener</var>, run these steps:

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

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

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

<li><p>If <var>eventTarget</var>'s <a>event listener list</a> does not <a for=list>contain</a> an
<a>event listener</a> whose <a for="event listener">type</a> is <var>listener</var>'s
<a for="event listener">type</a>, <a for="event listener">callback</a> is <var>listener</var>'s
Expand Down

0 comments on commit b294497

Please sign in to comment.