Skip to content

Reference to "global" in code intended to run in the browser #95

@notclive

Description

@notclive

When I try and use the local storage hook in a vite project, running in dev mode, I get the following error:

Uncaught ReferenceError: global is not defined

Line 14 of local-storage-events.ts references global.window. As far as I'm aware global isn't a global variable in browser environments.

From this discussion I've gathered that most, but not all, bundlers transform global to window.

Could line 14 be safely rewritten to the following?

    if (typeof window.CustomEvent === 'function') {
      return;
    }

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