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

API encourages writing platform-dependent code #6

Open
othermaciej opened this issue Sep 8, 2019 · 2 comments
Open

API encourages writing platform-dependent code #6

othermaciej opened this issue Sep 8, 2019 · 2 comments

Comments

@othermaciej
Copy link

The explainer and examples for the raw clipboard API encourage writing platform-dependent code, which is inconsistent with the nature of the web as a platform-independent meta-platform.

The following line results in functionality that would only work on Windows. That's clearly pretty terrible for any other platform, e.g. macOS.

if (navigator.clipboard.platform !== 'Windows') { return; }

The second example covers Windows, macOS and an else clause which is assumed to be Linux/X11. This omits Android and iOS, the two most popular platforms in the world, as well as any Linux configuration that doesn't use X11.

The third example covers only Windows and macOS.

The platform-independence of the web is a pretty important property. It allows web content and web apps to run anywhere, and enables the web to be brought to new platforms. This API would significantly chip away at that property.

@dway123
Copy link
Collaborator

dway123 commented Sep 10, 2019

Thank you for filing this. Platform-independent code should be preferred over platform-dependent code whenever possible, and this applies to usage of this API as well. I’ve clarified this in the explainer here.

Allowing raw clipboard access is necessary in order to allow web applications to encode/decode the long tail of formats that user agents will not standardize and implement for various reasons (proprietary format, low usage, cost of standardization, user agent binary size, etc).

Similarly, allowing platform-dependent code is also necessary in order to allow web applications to encode/decode formats that are implemented differently on different platforms. These formats often differ in binary representation on different platforms due to lack of platform standardization.

Some platforms were omitted in examples for the sake of brevity, but this API supports all platforms, and it is expected that web applications will support all platforms possible, especially as non-support of any platform will significantly decrease the potential reach and usefulness of their web application.

Some expected avenues for web applications to implement support for these formats on all platforms are (1) implementation by the web application, (2) porting an existing native application with existing encoders/decoders to the web, and (3) use of libraries which may provide encoding/decoding support.

@dway123
Copy link
Collaborator

dway123 commented Oct 30, 2019

We also discussed this in more detail here: w3c/clipboard-apis/issues/104.

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

2 participants