Re: [w3c/clipboard-apis] Defer OS clipboard read from clipboard.read() to ClipboardItem.getType() (PR #248)

@shwetabin commented on this pull request.



> @@ -918,6 +928,46 @@ url: https://storage.spec.whatwg.org/#obtain-a-storage-key-for-non-storage-purpo
 
     1. If |representation|'s [=representation/MIME type=] is |mimeType| and |representation|'s [=representation/isCustom=] is |isCustom|, then:
 
+     1. If [=this=]'s [=ClipboardItem/clipboard change count at read=] is not null, and the current [=clipboard change count=] is not equal to [=this=]'s [=ClipboardItem/clipboard change count at read=], then [=reject=] |p| with a {{"DataError"}} {{DOMException}} in |realm|, and return |p|.
+
+      Note: This ensures that stale data is never returned. If the [=system clipboard=] contents have changed since {{Clipboard/read()}} was called, this MUST fail rather than returning data that does not correspond to the current [=system clipboard=] state.
+
+      Note: A null [=ClipboardItem/clipboard change count at read=] indicates that this {{ClipboardItem}} was constructed directly by the author (e.g., via {{ClipboardItem/ClipboardItem(items, options)}}), not obtained from {{Clipboard/read()}}. In that case, no stale-data check is needed because the data does not originate from the [=system clipboard=].
+
+     1. If |representation|'s [=representation/data=] is not yet resolved, run the following steps [=in parallel=]:

Yes, I covered this in the latest update.
We now cache the first same-type getType() Promise in the resolver map and return it for subsequent calls, so no duplicate read/settle path can occur.

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

Message ID: <w3c/clipboard-apis/pull/248/review/4335518513@github.com>

Received on Thursday, 21 May 2026 09:07:31 UTC