Skip to content

Commit

Permalink
Remove WakeLockEvent and WakeLockEventInit.
Browse files Browse the repository at this point in the history
Per https://w3ctag.github.io/design-principles/#state-and-subclassing, we do
not really need a custom event class here.

`WakeLockEvent` has a single attribute, `lock`, that points to the event
target. That's exactly what `Event.target` also does, so we can just create
a simple `Event` instance and let the "fire an event" DOM algorithm set
`target` for us to achieve the same thing. In fact, it already does, so
before this commit we had

    ev.lock === ev.target

Fixes #238.
  • Loading branch information
rakuco committed Oct 18, 2019
1 parent 7383aff commit 826e89f
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -580,28 +580,6 @@ <h3>The <dfn>onrelease</dfn> attribute</h3>
</aside>
</section>
</section>
<section data-dfn-for="WakeLockEvent" data-link-for="WakeLockEvent">
<h2>The <dfn>WakeLockEvent</dfn> interface</h2>
<pre class="idl">
[SecureContext, Exposed=(DedicatedWorker, Window)]
interface WakeLockEvent : Event {
constructor(DOMString type, WakeLockEventInit init);
readonly attribute WakeLockSentinel lock;
};

dictionary WakeLockEventInit : EventInit {
required WakeLockSentinel lock;
};
</pre>
<p><a>WakeLockEvent</a> objects indicate that an event has happened to a
given <a>WakeLockSentinel</a> object. A <a>WakeLockEvent</a> is
dispatched when a <a>WakeLockSentinel</a>'s wake lock is released.</p>
<section>
<h3>The <dfn>lock</dfn> attribute</h3>
<p>The <a>lock</a> attribute is a <a>WakeLockSentinel</a> object whose
wake lock has been released.</p>
</section>
</section>
<section>
<h2>
Managing Wake Locks
Expand Down Expand Up @@ -824,10 +802,8 @@ <h3>
</li>
</ol>
</li>
<li><a>Fire an event</a> named "`release`" at |lock| using
<a>WakeLockEvent</a> with its <a
data-link-for="WakeLockEvent">lock</a> attribute initialized to
|sentinel|.</li>
<li><a>Queue a task</a> to <a>fire an event</a> named "`release`" at
|lock|.</li>
</ol>
</section>
</section>
Expand Down Expand Up @@ -883,7 +859,7 @@ <h2>

const listener = (ev) => {
checkbox.checked = false;
ev.lock.removeEventListener('release', listener);
ev.target.removeEventListener('release', listener);
};

lock.addEventListener('release', listener);
Expand Down

0 comments on commit 826e89f

Please sign in to comment.