diff --git a/index.bs b/index.bs index a55b526..82d8b9e 100644 --- a/index.bs +++ b/index.bs @@ -68,6 +68,7 @@ urlPrefix: https://w3c.github.io/geolocation-api/; spec: geolocation url:#dom-geolocation-watchposition; type:method; for:Geolocation; text:watchPosition() urlPrefix: https://html.spec.whatwg.org/multipage/; spec: HTML url: system-state.html#dom-navigator-online; type: attribute; for: NavigatorOnline; text: onLine; + url: media.html#dom-media-play; type:method; for:HTMLMediaElement; text:play() urlPrefix: https://w3c.github.io/remote-playback/; spec: REMOTE-PLAYBACK url: #remoteplayback-interface; type:interface; text: RemotePlayback url: #dfn-remote-playback-devices; type:dfn; text: remote playback device @@ -1877,6 +1878,56 @@ If the bytes in the buffer have a natural intepretation as one of the other TypedArray types, provide that instead. For example, if the bytes represent Float32 values, use a {{Float32Array}}. +

Return undefined from side-effect-causing functions

+ + + +When the purpose of a function +is to cause side effects +and not to compute a value, +the function should be specified +to return {{undefined}}. + +Sites are unlikely +to come to depend on +such a return value, +which makes it easier +to change the function +to return a meaningful value +in the future +should a use case for one be discovered. + +
+ +{{HTMLMediaElement}}’s {{HTMLMediaElement/play()}} method +was originally defined to return {{undefined}}, +since its purpose was +to change the state +of the media element. + +Requests to play media +can fail +in a number of ways, +so {{HTMLMediaElement/play()}} was [changed](https://github.com/whatwg/html/issues/505) +to return a {{Promise}}. +If the API +had originally been defined +to return something other than {{undefined}} +(for example, +if it had been defined +to return the media element, +a popular pattern +in “chaining” APIs), +it would not have been backwards compatible +to enhance the usability of this API +in this manner. + +
+ +See also: + +* [Command–query separation on Wikipedia](https://en.wikipedia.org/wiki/Command–query_separation) +

Event Design

Use promises for one time events