Skip to content

Commit

Permalink
Make "type" an optional parameter for WakeLock.request(). (#291)
Browse files Browse the repository at this point in the history
And make it default to "screen". Existing code continues to work, while new
code can also call `navigator.wakeLock.request()` to request a screen wake
lock.

Issues #253, #255 and #288 indicate that there is a preference for making
`type` an optional parameter that just got overlooked.
  • Loading branch information
Raphael Kubo da Costa authored Oct 5, 2020
1 parent f89b85a commit 58a7bb0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ if (lock.released === false) {

### Requesting permission to use WakeLocks
To use the API, one must request access via
`navigator.wakeLock.request("screen")`. This returns a promise which, if
allowed by the user, resolves with a `WakeLockSentinel`.
`navigator.wakeLock.request("screen")` (`"screen"` is optional). This
returns a promise which, if allowed by the user, resolves with a
`WakeLockSentinel`.

```js
let sentinel;
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ <h2>
<pre class="idl">
[SecureContext, Exposed=(Window)]
interface WakeLock {
Promise&lt;WakeLockSentinel&gt; request(WakeLockType type);
Promise&lt;WakeLockSentinel&gt; request(optional WakeLockType type = "screen");
};
</pre>
<section>
Expand Down

0 comments on commit 58a7bb0

Please sign in to comment.