Skip to content

Commit

Permalink
fix: self and global error in alipay appx (mobxjs#2071)
Browse files Browse the repository at this point in the history
* fix: self and global error in alipay appx

* Updated changelog
  • Loading branch information
doxiaodong authored and FredyC committed Aug 9, 2019
1 parent ec011d5 commit cb07a4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.13.1 / 4.13.1

* Don't use `global` and `self` keywords unless defined. Fixes [#2070](https://github.com/mobxjs/mobx/issues/2070).

# 5.13.0 / 4.13.0

* Fixed potential memory leak in observable maps, when non-primitive values are used as keys. Fixes [#2031](https://github.com/mobxjs/mobx/issues/2031) through [#2032](https://github.com/mobxjs/mobx/pull/2032).
Expand Down
10 changes: 9 additions & 1 deletion src/core/globalstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ export function resetGlobalState() {

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
}
4 changes: 2 additions & 2 deletions src/utils/iterable.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export function makeIterable<T>(iterator: Iterator<T>): IterableIterator<T> {
iterator[Symbol.iterator] = self
iterator[Symbol.iterator] = getSelf
return iterator as any
}

function self() {
function getSelf() {
return this
}

0 comments on commit cb07a4f

Please sign in to comment.