From 826e89fc26938351ec46f23bbf2bff7edbf271f5 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Thu, 17 Oct 2019 10:50:55 +0200 Subject: [PATCH] Remove WakeLockEvent and WakeLockEventInit. 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. --- index.html | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index 05c55eb..2cd71a3 100644 --- a/index.html +++ b/index.html @@ -580,28 +580,6 @@

The onrelease attribute

-
-

The WakeLockEvent interface

-
-        [SecureContext, Exposed=(DedicatedWorker, Window)]
-        interface WakeLockEvent : Event {
-          constructor(DOMString type, WakeLockEventInit init);
-          readonly attribute WakeLockSentinel lock;
-        };
-
-        dictionary WakeLockEventInit : EventInit {
-          required WakeLockSentinel lock;
-        };
-      
-

WakeLockEvent objects indicate that an event has happened to a - given WakeLockSentinel object. A WakeLockEvent is - dispatched when a WakeLockSentinel's wake lock is released.

-
-

The lock attribute

-

The lock attribute is a WakeLockSentinel object whose - wake lock has been released.

-
-

Managing Wake Locks @@ -824,10 +802,8 @@

-
  • Fire an event named "`release`" at |lock| using - WakeLockEvent with its lock attribute initialized to - |sentinel|.
  • +
  • Queue a task to fire an event named "`release`" at + |lock|.
  • @@ -883,7 +859,7 @@

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