v133 · miscellaneous
Support creating ClipboardItem with Promise<DOMString>
The ClipboardItem, which is the input to the async clipboard write method, now accepts string values in addition to Blobs in its constructor. ClipboardItemData can be a Blob, a string, or a Promise that resolves to either a Blob or a string.
concepts
-
ClipboardItem<Promise>
ClipboardItem accepts a Promise<DOMString> for lazy / async content. Lets writers defer until write time.
-
Async screenshot copy
The motivating use case: a heavy chart render kicks off on click and copies as PNG. Side-by-side comparison shows the old await-then-write hitting NotAllowedError vs the new promise path succeeding.
-
Multi-format clipboard builder
Compose a single
ClipboardItemwithtext/plain+text/html(and a PNG) at once — strings or promises — without wrapping inBlob. -
Deferred content lab
Three distinct deferred-content patterns — lazy template, timed delay, computed diff — each showing why
Promise<DOMString>inClipboardItemsucceeds where the old await-then-write pattern fails.
why it shipped
The current implementation of the ClipboardItem constructor accepts data as either a Blob or a Promise<Blob>. However, according to the Clipboard API specification, the constructor should accept ClipboardItemData, which can include Promise<(DOMString or Blob)>.