diff --git a/.changeset/five-news-hammer.md b/.changeset/five-news-hammer.md new file mode 100644 index 000000000..e7f7792a4 --- /dev/null +++ b/.changeset/five-news-hammer.md @@ -0,0 +1,5 @@ +--- +"mobx": patch +--- + +Fix browser compatability issue introduced in 6.13.4 release diff --git a/packages/mobx/src/utils/iterable.ts b/packages/mobx/src/utils/iterable.ts index c05384ef0..59463bb47 100644 --- a/packages/mobx/src/utils/iterable.ts +++ b/packages/mobx/src/utils/iterable.ts @@ -1,5 +1,15 @@ +import { getGlobal } from "../internal" + +// safely get iterator prototype if available +const maybeIteratorPrototype = getGlobal().Iterator?.prototype || {} + export function makeIterable( iterator: Iterator ): IteratorObject { - return Object.assign(Object.create(Iterator.prototype), iterator) + iterator[Symbol.iterator] = getSelf + return Object.assign(Object.create(maybeIteratorPrototype), iterator) +} + +function getSelf() { + return this }