Skip to content

Types don't reflect that clipboard is undefined in insecure contexts #14

@ysangkok

Description

@ysangkok

The referenced w3 API specifies:

partial interface [Navigator](https://html.spec.whatwg.org/multipage/system-state.html#navigator) {
  [[SecureContext](https://webidl.spec.whatwg.org/#SecureContext), [SameObject](https://webidl.spec.whatwg.org/#SameObject)] readonly attribute [Clipboard](https://www.w3.org/TR/clipboard-apis/#clipboard) [clipboard](https://www.w3.org/TR/clipboard-apis/#dom-navigator-clipboard);
};

and sure enough, on insecure pages (with window.isSecureContext === false) like about:blank (or any other HTTP pages), window.clipboard is undefined.

For me, this meant that calling writeText caused my Effect computation to abort (with no error!) See screenshot:

image

I am not sure what the right way to address this should be. Should clipboard have type Window -> Maybe Clipboard instead? Internally, it could check for undefined. That might be more robust than checking isSecureContext.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions