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

trflynn89 created an issue (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`.

<hr />

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)).



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

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

Received on Thursday, 1 May 2025 20:08:46 UTC