Open othermaciej opened 4 years ago
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.
We also discussed this in more detail here: w3c/clipboard-apis/issues/104.
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.
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.