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

> optional with CaptureController? controller = null;- even though it is already optional according to https://webidl.spec.whatwg.org/#dictionary-member-optional,

You are correct we need `?` here, thanks for catching this! I've written https://github.com/w3c/mediacapture-screen-share/pull/238 to take care of this.

Note that `?` makes it _[nullable](https://webidl.spec.whatwg.org/#idl-nullable-type)_, which it has to be to have a default value of `null`, not optional, which you are correct to observe that dictionary members already are when they aren't qualified with the [required](https://webidl.spec.whatwg.org/#required-dictionary-member) keyword.

> Note that https://github.com/whatwg/webidl/pull/1205 would go towards removing the null part and simply have `CaptureController controller;`.

That PR [removed](https://github.com/whatwg/webidl/pull/1205/files) nullable from DOMString members, which I approve of, because nullable strings have poor characteristics (they introduce type-duality since `typeof null` is `"object"` not `"string"`). `null` also has terrible conversion properties to string in JS (`"" + undefined` produces `"undefined"`).

But I disagree with the OP in that PR that members need to be required to be nullable. I see no support for such a position from first principles, nor do I interpret the fact that it went unchallenged in review since the PR itself was fine.

> What are the arguments for making this nullable, when this member is already optional?

The argument is that `null` is the natural default value for this argument in the [getDisplayMedia](https://w3c.github.io/mediacapture-screen-share/#dom-mediadevices-getdisplaymedia) algorithm where it is used as input, [as argued by you](https://github.com/w3c/mediacapture-screen-share/pull/235#discussion_r983553441) (I agree with you on this, since this is likely to be written in c++).

AFAIK there is no web developer observable difference here, so this should suffice as an argument I think?

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