Skip to content

Commit

Permalink
fix: self and global error in alipay appx (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
doxiaodong authored and FredyC committed Aug 9, 2019
1 parent 97218df commit 9a40d66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils/iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export function declareIterator<T>(prototType, iteratorFactory: () => IterableIt
}

export function makeIterable<T>(iterator: Iterator<T>): IterableIterator<T> {
iterator[iteratorSymbol()] = self
iterator[iteratorSymbol()] = getSelf
return iterator as any
}

export function toStringTagSymbol() {
return (typeof Symbol === "function" && Symbol.toStringTag) || "@@toStringTag"
}

function self() {
function getSelf() {
return this
}
10 changes: 9 additions & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ Object.freeze(EMPTY_OBJECT)

declare const window: any

const mockGlobal = {}

export function getGlobal() {
return typeof window !== "undefined" ? window : global
if (typeof window !== "undefined") {
return window
}
if (typeof global !== "undefined") {
return global
}
return mockGlobal
}

export interface Lambda {
Expand Down

0 comments on commit 9a40d66

Please sign in to comment.