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

why "optional" in share(optional ShareData data)? #109

Closed
marcoscaceres opened this issue Jul 2, 2019 · 1 comment · Fixed by #111
Closed

why "optional" in share(optional ShareData data)? #109

marcoscaceres opened this issue Jul 2, 2019 · 1 comment · Fixed by #111

Comments

@marcoscaceres
Copy link
Member

Given that the first thing we need to check is if data has some members, shouldn't the share() signature actually make data required?

Alternatively, the method signature should default to the empty dictionary:

[SecureContext] Promise<void> share(optional ShareData data = {});

However, I think we should just make data required.

@ewilligers
Copy link
Collaborator

See the first note in https://wicg.github.io/web-share/level-2/#navigator-interface

The data argument is marked as "optional", but it is effectively required; share() will return a rejected promise with a TypeError if called with no arguments. WebIDL mandates that it be optional because the dictionary members are all optional. See WebIDL Issue #130.

https://heycam.github.io/webidl/#idl-operations

If the type of an argument is a dictionary type or a union type that has a dictionary type as one of its flattened member types, and that dictionary type and its ancestors have no required members, and the argument is either the final argument or is followed only by optional arguments, then the argument must be specified as optional and have a default value provided.

We should add = {}

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

Successfully merging a pull request may close this issue.

2 participants