Skip to content

Commit

Permalink
fix(globalThis): fix ReferenceError (#309)
Browse files Browse the repository at this point in the history
ReferenceError: self is not defined
#308
  • Loading branch information
hero-guo authored and janryWang committed Sep 17, 2019
1 parent 7fe42c7 commit 9efc90a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/utils/src/globalThis.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
export const globalThisPolyfill =
self || window || global || Function('return this')()
function globalThis() {
if (typeof self !== 'undefined') {
return self
}
if (typeof window !== 'undefined') {
return window
}
if (typeof global !== 'undefined') {
return global
}
return Function('return this')()
}
export const globalThisPolyfill = globalThis()

0 comments on commit 9efc90a

Please sign in to comment.