- From: roraja <notifications@github.com>
- Date: Wed, 28 Jan 2026 10:45:13 -0800
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/clipboard-apis/issues/240/3813169825@github.com>
roraja left a comment (w3c/clipboard-apis#240)
I've been thinking more about the lazy `getType()` approach (Option 2) and want to raise some concerns about what this does to ClipboardItem's semantics.
The core issue is that lazy `getType()` transforms ClipboardItem from a **data object** (snapshot of clipboard at read-time) to a **service proxy** (lazy fetcher that may fail if clipboard changed). This is a fundamental semantic shift which might confuse web developers.
Consider the current interface:
```jsx
readonly attribute FrozenArray<DOMString> types;
Promise<Blob> getType(DOMString type);
```
The `types` property is a `FrozenArray`—explicitly immutable—which signals to developers: "these types are fixed and available." But with lazy `getType()`, this becomes misleading. A developer might see `types` includes `"text/plain"`, call `getType("text/plain")`, and get an error/empty data because the clipboard changed. The `FrozenArray` implied availability that doesn't exist.
More fundamentally, the spec describes ClipboardItem as:
> "conceptually data that the user has expressed a desire to make shareable by invoking a 'cut' or 'copy' command."
>
This is snapshot language—data from a past action. Lazy `getType()` changes this to: "a handle to whatever is currently on the clipboard, which may or may not match what was there when you called read()."
However, if a web developer creates a new ClipboardItem for writing purpose, then the semantic meaning again switches back to being a “fronzen data container”, further adding to the confusion for web developers and creating inconsistency in the interface.
```jsx
// This now acts like a frozen data object, getType won't error out if clipboard changes
const item = new ClipboardItem({ "txt/plain": "My text", “txt/html”: “My html” })
navigator.clipboard.write(item)
```
So "ClipboardItem" now behaves both like a frozen data object when created explicitly by web author and also like a service proxy which fetches latest data or empty data if the clipboard changed after read() call. I think makes the API look not simple to understand and unintuitive as the web developer has to understand all these special cases under which the behavior changes.
Any thoughts ?
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/240#issuecomment-3813169825
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/clipboard-apis/issues/240/3813169825@github.com>
Received on Wednesday, 28 January 2026 18:45:17 UTC