[clipboard-apis] The ClipboardEvent constructor is strange (#10)

https://w3c.github.io/clipboard-apis/#clipboard-event-interfaces

There's an effort to implement the `ClipboardEvent` constructor in Blink:
https://code.google.com/p/chromium/issues/detail?id=496394
https://codereview.chromium.org/1178683007/

In the review I noticed some weird things, quoted here:

> The spec is strange and I think it probably needs to be fixed a bit in order to be implemented. It looks like Firefox doesn't actually do what it says either, at least judging by this: new ClipboardEvent({data:'foo',dataType:'text/plain'}).clipboardData.types

> the spec expresses this differently, and is pretty weird to me. As part of "fire a clipboard event" it checks if the event is trusted and uses the data and dataType arguments from the constructor without actually storing somewhere in the interim. If actually implemented like this, we'd have to add the entry to the DataTransferItemList when the event is fired, not in the constructor.

> Also strange is that there's no way to actually run the "fire a clipboard event" algorithm from scripts, all of the entry points look like they're for actual copy/paste/cut actions.

How should we reach interoperability here? To me the `data` and `dataType` members don't seem very useful, and it would be more in line with other event constructors to simply take a `clipboardData` attribute. If `DataTransfer` doesn't have a constructor, maybe it should? If it shouldn't, then perhaps a `ClipboardEvent` constructor doesn't make sense either.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/10

Received on Tuesday, 30 June 2015 09:46:22 UTC