Re: [w3c/clipboard-apis] Questions about implementing `clipboard.write` (Issue #237)

EdgarChen left a comment (w3c/clipboard-apis#237)

> In the following steps, iterating over `itemList`:
> 
> https://w3c.github.io/clipboard-apis/#dom-clipboard-write
> 
> ```
> 4. For each clipboardItem in dataList:
>     1. For each representation in clipboardItem’s clipboard item's list of representations:
>         (in this loop, we add items to `itemList`
>     2. For each blob in itemList:
>         5. Append cleanItem to cleanItemList.
>     3. Let option be clipboardItem’s clipboard item's presentation style.
>     4. Write blobs and option to the clipboard with cleanItemList and option.
> ```
> 
> After we write`cleanItemList` to the clipboard, we do not clear `itemList` over `clearItemList`. So on the next iteration of `dataList`, won't we write those same items again? These lists will just keep growing as we loop over `dataList`.

Perhaps the declaration of `itemList` and `cleanItemList` should be moved into the iteration of `dataList`?

> In the same steps, the spec seems to assume that the "2. React to representationDataPromise:" step will react synchronously. In practice, this occurs asynchronously, because even when the promise is already resolved, the reaction steps ultimately queue a microtask to run the fulfillment/rejection steps (via [HostEnqueuePromiseJob](https://html.spec.whatwg.org/multipage/webappapis.html#hostenqueuepromisejob)).

Yes, and the write-to-clipboard step should wait until all promises are resolved.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/237#issuecomment-2852552253
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/issues/237/2852552253@github.com>

Received on Monday, 5 May 2025 22:48:29 UTC