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

I'm trying to back up my statements, but its making me fall behind in the conversation, so apologies for taking a bit to address all the claims being made here. I would encourage others to back up opinions with supporting documents as well.

> it's better to explicitly handle the case where optional members are omitted.

This seems to go against [6.5. Make method arguments optional if possible](https://w3ctag.github.io/design-principles/#optional-parameters) which says defaults are good: _"If an argument for an API method has a reasonable default value, make that argument optional and specify the default value."_

Default values prevent an implementation from telling the difference between whether a member is present with the default value or absent. This seems a desirable invariant for all algorithms except those that overload these differences with additional semantics, and such subtlety generally seems like a bad idea to me, and is not the case here.

> This might be observable if passing null would reject getDisplayMedia promise in one case and not the other.

> Why allowing to pass a null value and an undefined value to controller field?

> Are there existing APIs doing so?

I believe the [Nullable conversion steps](https://webidl.spec.whatwg.org/#es-nullable-type) allow `undefined` to be coerced to `null`: _"Otherwise, if V is null or undefined, then return the IDL [nullable type](https://webidl.spec.whatwg.org/#dfn-nullable-type) T? value null."_ So I believe all APIs that take nullable types do this. Again, I see not web developer impact here, but please prove me wrong, as I cannot prove a negative.

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/236#issuecomment-1263721588 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 15:31:18 UTC