Skip to content

Commit

Permalink
fix(globalThis): fix ReferenceError (alibaba#309)
Browse files Browse the repository at this point in the history
ReferenceError: self is not defined
alibaba#308
  • Loading branch information
hero-guo authored and anyuxuan committed Nov 14, 2019
1 parent da6416f commit f6d93f1
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 f6d93f1

Please sign in to comment.