Re: [mediacapture-screen-share] Address nullability of DisplayMediaStreamOptions.controller (#236)

> ... but that's how JavaScript does this.

Default function arguments in JS [seem to work that way, while `??` works another](https://jsfiddle.net/jib1/zoxepamv/), treating `null` and `undefined` the same. But those aren't examples of throwing or rejecting. Where does JS throw or reject on `null`?

If we reject on `null`, then the subset of web developers who operate in larger code bases that use `null` liberally might end up writing defensive code now in order to separate concerns:
```js
async function foo(controller) {
  await navigator.mediaDevices.getDisplayMedia({controller: controller ?? undefined});
}
```
This seem sub-optimal. While a controller of `false` or `0` is a type mismatch, `null` isn't in JS (`typeof new CaptureController()` and `typeof null` are both `"object"`).

What's the specific advantage of treating `controller: null` as an error here instead of "no controller"?

Also, when is `null` to be used?

> https://w3ctag.github.io/design-principles/#optional-parameters

This concerns method arguments. Does this mean we're also moving toward:
```js
platformObj.foo("hi", undefined, 3); // accepted
platformObj.foo("hi", null, 3); // TypeError ?
``` 

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/236#issuecomment-1263849689 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 30 September 2022 17:47:17 UTC