scala-js / scala-js-dom

Statically typed DOM API for Scala.js
Other
315 stars 160 forks source link

`Clipboard#{read,write}` are wrong #730

Closed armanbilge closed 1 year ago

armanbilge commented 1 year ago

According to the MDN docs, read and write should be in terms of a js.Array[ClipboardItem]. But that's not what a DataTransfer is ...

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard

https://github.com/scala-js/scala-js-dom/blob/51a807cc04ea134ece030d6d4005a8ce30c1de99/dom/src/main/scala/org/scalajs/dom/Clipboard.scala#L28

https://github.com/scala-js/scala-js-dom/blob/51a807cc04ea134ece030d6d4005a8ce30c1de99/dom/src/main/scala/org/scalajs/dom/Clipboard.scala#L41

zetashift commented 1 year ago

I can pick this up if you like!

armanbilge commented 1 year ago

@zetashift yes please! 😃 I have a renewed interest in all these APIs because of my new fs2-dom pet project 😋

zetashift commented 1 year ago

From https://w3c.github.io/clipboard-apis/#dom-clipboard-write

I can't exactly figure out what kind of promise it should return?

Currently have this:

  def write(data: DataTransfer): js.Promise[ClipboardItem] = js.native
armanbilge commented 1 year ago

@zetashift I think it should be this

  def write(data: ClipboardItems): js.Promise[Unit] = js.native

undefined is () aka Unit in Scala.js