Skip to content

Commit

Permalink
fix: handle globalThis undefined in legacy browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 24, 2020
1 parent ff98da6 commit b83c59b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runtime/browser/global.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable no-restricted-globals */

function getGlobal() {
if (typeof globalThis !== 'undefined') return globalThis
if (typeof self !== 'undefined') return self
if (typeof window !== 'undefined') return window
throw new Error('unable to locate global object')
}

export default globalThis || getGlobal()
export default getGlobal()

0 comments on commit b83c59b

Please sign in to comment.