Skip to content

Commit

Permalink
fix(Symbol.iterator): correctly handle case where Symbol constructor …
Browse files Browse the repository at this point in the history
…itself is not defined (#3394)
  • Loading branch information
jayphelps authored and benlesh committed Mar 8, 2018
1 parent 923ce05 commit 6725be1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/internal/symbol/iterator.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
export function getSymbolIterator(): symbol {
/* NOTE: Warning users that they don't have a Symbol.iterator
polyfill. We don't want to throw on this, because it's not required
by the library. However it will provide clues to users on older
browsers why things like `from(iterable)` doesn't work. */
if (typeof Symbol !== 'function' || !Symbol.iterator) {
console.warn('RxJS: Symbol.iterator does not exist, so things like from(iterable) won\'t work');
return '@@iterator' as any;
}

/* NOTE: Warning users that they don't have a Symbol.iterator
polyfill. We don't want to throw on this, because it's not required
by the library. However it will provide clues to users on older
browsers why things like `from(iterable)` doesn't work. */
if (!Symbol || !Symbol.iterator) {
console.warn('RxJS: Symbol.observable does not exist');
return Symbol.iterator;
}

/** The native Symbol.iterator instance or a string */
export const iterator = Symbol && Symbol.iterator || '@@iterator';
export const iterator = getSymbolIterator();

/**
* @deprecated use {@link iterator} instead
Expand Down

0 comments on commit 6725be1

Please sign in to comment.