Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionary with required members as optional argument #1378

Open
Ms2ger opened this issue Dec 13, 2023 · 4 comments
Open

Dictionary with required members as optional argument #1378

Ms2ger opened this issue Dec 13, 2023 · 4 comments

Comments

@Ms2ger
Copy link
Member

Ms2ger commented Dec 13, 2023

What is the issue with the Web IDL Standard?

CSP has this IDL code (:

[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, 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.

@evilpie
Copy link

evilpie commented Dec 13, 2023

It seems like a more explicit definition would be good, but "an object with no properties" seems like the obvious default initialization for a dictionary parameter?

@domenic
Copy link
Member

domenic commented Dec 13, 2023

This is a dupe of whatwg/dom#600.

@domenic domenic closed this as completed Dec 13, 2023
@domenic
Copy link
Member

domenic commented Dec 13, 2023

Hmm, I guess this is about the web-developer-facing interfaces, whereas whatwg/dom#600 is about the spec interface.

But for the web developer-facing interface, this seems like a bug in the CSP spec, not the Web IDL spec.

@domenic domenic reopened this Dec 13, 2023
@Ms2ger
Copy link
Member Author

Ms2ger commented Dec 13, 2023

I think there's an IDL bug here that's wider than just events if optional Dict foo = {} is legal IDL when Dict has required members

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants