Skip to content

Commit

Permalink
Update "Observing event listeners" section
Browse files Browse the repository at this point in the history
  • Loading branch information
RByers committed Sep 25, 2015
1 parent bce63a3 commit 29925e7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
31 changes: 16 additions & 15 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,21 +1135,22 @@ method must run these steps:
</ol>

<h3 id=observing-event-listeners>Observing event listeners</h3>
This section is non-normative.

In general, the mere presence of an event listener should not result in any
behavior change. Developers don't expect an event listener to have any impact
on behavior other than that done explicitly by their callback.

However, in some cases a user agent may make important performance optimizations
in scenarios where there are no event listeners of a given type (such as by leaving
a sensor disabled when there are no consumers for the data). In rare cases, a
particular type of event may be specified to be cancelable only when there is at
least one non-passive listener. For example, non-passive touch event listeners
must blocking scrolling, but if all listeners are passive then a performance
optimization is possible by making the event uncancelable. New event types
should be defined such that they don't need this property (use
<a href="https://lists.w3.org/Archives/Public/public-script-coord/">public-scrip-coord</a>
In general, developers don't expect the presence of an event listener to be
observable. The impact of an event listener is determined by it's callback.
That is, a developer adding a no-op event listener would not expect it to have
any side effects.

Unfortunately, some event APIs have been designed such that implementing them
efficiently requires observing event listeners. For example, sensor APIs which
enable an underlying device sensor, and touch APIs which can be used to block
async scrolling. In some cases this problem can be mitigated by specifying
the event to be {{Event/cancelable}} only when there is at least one
non-{{EventListenerOptions/passive}} listener. For example, non-passive
{{TouchEvent}} listeners must block scrolling, but if all listeners are passive then
scrolling can be allowed to start asynchronously by making the {{TouchEvent}}
uncancelable (so that calls to {{Event/preventDefault()}} are ignored).
New event types should be defined such that they don't need this
property (use <a href="https://lists.w3.org/Archives/Public/public-script-coord/">public-scrip-coord@w3.org</a>
for discussion).

<h3 id=dispatching-events>Dispatching events</h3>
Expand Down
27 changes: 14 additions & 13 deletions dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<div class="head">
<p data-fill-with="logo"><a class="logo" href="https://whatwg.org/"> <img alt="WHATWG" height="100" src="https://resources.whatwg.org/logo-dom.svg"> </a> </p>
<h1 class="p-name no-ref allcaps" id="title">DOM</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated <time class="dt-updated" datetime="2015-09-24">24 September 2015</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated <time class="dt-updated" datetime="2015-09-25">25 September 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>Participate:
Expand Down Expand Up @@ -767,18 +767,19 @@ <h3 class="heading settled" data-level="3.7" id="interface-eventtarget"><span cl
<li><a data-link-type="dfn" href="#concept-event-dispatch">Dispatch</a> the <var>event</var> and return the value that returns.
</ol>
<h3 class="heading settled" data-level="3.8" id="observing-event-listeners"><span class="secno">3.8. </span><span class="content">Observing event listeners</span><a class="self-link" href="#observing-event-listeners"></a></h3>
This section is non-normative.
<p>In general, the mere presence of an event listener should not result in any
behavior change. Developers don’t expect an event listener to have any impact
on behavior other than that done explicitly by their callback.</p>
<p>However, in some cases a user agent may make important performance optimizations
in scenarios where there are no event listeners of a given type (such as by leaving
a sensor disabled when there are no consumers for the data). In rare cases, a
particular type of event may be specified to be cancelable only when there is at
least one non-passive listener. For example, non-passive touch event listeners
must blocking scrolling, but if all listeners are passive then a performance
optimization is possible by making the event uncancelable. New event types
should be defined such that they don’t need this property (use <a href="https://lists.w3.org/Archives/Public/public-script-coord/">public-scrip-coord</a> for discussion).</p>
In general, developers don’t expect the presence of an event listener to be
observable. The impact of an event listener is determined by it’s callback.
That is, a developer adding a no-op event listener would not expect it to have
any side effects.
<p>Unfortunately, some event APIs have been designed such that implementing them
efficiently requires observing event listeners. For example, sensor APIs which
enable an underlying device sensor, and touch APIs which can be used to block
async scrolling. In some cases this problem can be mitigated by specifying
the event to be <code class="idl"><a data-link-type="idl" href="#dom-event-cancelable">cancelable</a></code> only when there is at least one
non-<code class="idl"><a data-link-type="idl" href="#dom-eventlisteneroptions-passive">passive</a></code> listener. For example, non-passive <code class="idl"><a data-link-type="idl" href="http://www.w3.org/TR/touch-events/#touchevent-interface">TouchEvent</a></code> listeners must block scrolling, but if all listeners are passive then
scrolling can be allowed to start asynchronously by making the <code class="idl"><a data-link-type="idl" href="http://www.w3.org/TR/touch-events/#touchevent-interface">TouchEvent</a></code> uncancelable (so that calls to <code class="idl"><a data-link-type="idl" href="#dom-event-preventdefault">preventDefault()</a></code> are ignored).
New event types should be defined such that they don’t need this
property (use <a href="https://lists.w3.org/Archives/Public/public-script-coord/">public-scrip-coord@w3.org</a> for discussion).</p>
<h3 class="heading settled" data-level="3.9" id="dispatching-events"><span class="secno">3.9. </span><span class="content">Dispatching events</span><a class="self-link" href="#dispatching-events"></a></h3>
<p>To <dfn data-dfn-for="Event" data-dfn-type="dfn" data-export="" id="concept-event-dispatch">dispatch<a class="self-link" href="#concept-event-dispatch"></a></dfn> an <a data-link-type="dfn" href="#concept-event">event</a> to a
given object, with an optional <var>target override</var>, run these steps:</p>
Expand Down

0 comments on commit 29925e7

Please sign in to comment.