[whatwg/webidl] Dictionary with required members as optional argument (Issue #1378)

### What is the issue with the Web IDL Standard?

CSP has this IDL code (:
```webidl
[Exposed=(Window,Worker)]
interface SecurityPolicyViolationEvent : Event {
    constructor (DOMString type, optional SecurityPolicyViolationEventInit eventInitDict = {});
    // ...
};

dictionary SecurityPolicyViolationEventInit : EventInit {
    required USVString      documentURI;
    // ...
};
```
which IDL doesn't, as far as I can tell, expect or handle well.

If I'm not mistaken, when handling `new SecurityPolicyViolationEvent("type")`, the overload resolution algorithm just passes "that default value" in step 15.4.1, and nothing really defines what that value is ("which represents a default-initialized (as if from ES null or an object with no properties) dictionary value").

The behavior of the constructor is specified in [DOM](https://dom.spec.whatwg.org/#constructing-events), which doesn't pay attention to the requiredness of dictionary members.

It appears to me that as currently specified, the `required` tokens are essentially ignored when the argument is omitted. This seems unexpected at least.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1378
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1378@github.com>

Received on Wednesday, 13 December 2023 09:35:16 UTC