- From: jan-ivar <notifications@github.com>
- Date: Fri, 01 Jun 2018 15:35:30 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/issues/76/394027017@github.com>
> similarly to how we require dictionaries to always be optional arguments
But we don't. We can write:
```js
dictionary Foo { required long foo1; };
dictionary Bar { required Foo myFoo; };
void doFoo(Foo myFoo);
void doStuff(Bar myBar);
```
`doFoo()` throws `TypeError: Not enough arguments to Jib.doFoo`.
`doFoo({})` throws `TypeError: Missing required 'foo1' member of Foo`.
`doStuff()` throws `TypeError: Not enough arguments to Jib.doStuff`.
`doStuff({})` throws `TypeError: Missing required 'myFoo' member of Bar`.
`doStuff({myFoo: {}})` throws `TypeError: Missing required 'foo1' member of Foo`.
`doStuff({myFoo: {foo1: 1}})` succeeds.
> I don't think there's a good reason to make dictionary handling inconsistent between it being an argument and a member of another dictionary.
Function arguments are required by default whereas dictionary members are optional by default, so I don't see what consistency we'd be upholding.
At least two specs interpret:
```js
dictionary Foo { required long foo1; };
dictionary Bar { Foo myFoo; };
```
to mean `doStuff()` should succeed. Exhibit A: [PaymentDetailsModifier](https://w3c.github.io/payment-request/#paymentdetailsmodifier-dictionary), Exhibit B: [MediaConfiguration](https://wicg.github.io/media-capabilities/#dictdef-mediaconfiguration):
```
dictionary MediaConfiguration {
VideoConfiguration video;
AudioConfiguration audio;
};
```
[says](https://wicg.github.io/media-capabilities/#dom-mediacapabilities-decodinginfo%E2%91%A0):
*"If configuration.video is [present](https://heycam.github.io/webidl/#present) and is [not a valid video configuration](https://wicg.github.io/media-capabilities/#valid-video-configuration), return a Promise rejected with a TypeError. "*
I.e. they expect `{ audio: {contentType: 'audio/webm; codecs=opus'}}` to not throw TypeError,
and `{ audio: {contentType: 'audio/webm; codecs=opus'}, video: {}}` to throw TypeError.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/76#issuecomment-394027017
Received on Friday, 1 June 2018 22:35:52 UTC