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

  1. ClipboardItem<Promise>

    ClipboardItem accepts a Promise<DOMString> for lazy / async content. Lets writers defer until write time.

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

  3. Multi-format clipboard builder

    Compose a single ClipboardItem with text/plain + text/html (and a PNG) at once — strings or promises — without wrapping in Blob.

  4. Deferred content lab

    Three distinct deferred-content patterns — lazy template, timed delay, computed diff — each showing why Promise<DOMString> in ClipboardItem succeeds 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)>.

references