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

navigator.share() should throw a TypeError if all fields are omitted #48

Closed
mgiuca opened this issue Jun 28, 2017 · 0 comments
Closed

Comments

@mgiuca
Copy link
Collaborator

mgiuca commented Jun 28, 2017

The following call:

navigator.share({foo: 'xyz'})

Currently results in a successful share with no data.

It should reject with a TypeError.

Rationale: Empty shares are a bad user experience. They show up in the target application as empty strings which is confusing. There's the simple case of passing an empty dictionary to share, but we also have to consider the more plausible case of adding new fields in the future, and how sites that use the new API will interact with old UAs that don't support those new fields.

The current status quo is that if you share only new fields, you'll share nothing on an old UA.

We should offer feature detection for these new fields (see WebIDL #107) and then make it a TypeError if you fail to properly use the feature detection and only share new fields.

This is related to #47 which is about making navigator.share() equivalent to navigator.share({}). If we make this change, navigator.share() would remain a TypeError which makes me happy. I think navigator.share() being a successful share is nonsensical.

@mgiuca mgiuca closed this as completed in #50 Jul 4, 2017
mgiuca added a commit that referenced this issue Jul 4, 2017
This makes sharing the empty dictionary, or a dictionary with only
unrecognised fields, a programmer error, and is designed to aid in
future extensions (since if new fields are added, it will be a TypeError
to exclusively use them without feature detection).

Closes #48.
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

No branches or pull requests

1 participant