Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve yield * issues for Firefox < 45 #278

Merged
merged 2 commits into from
Apr 28, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix @@iterator function call for generators, so that the generator it…
…self is returned.
  • Loading branch information
rayd committed Feb 22, 2017
commit 6480f91c2d2dba786e51c19019c113e618d5b262
19 changes: 12 additions & 7 deletions packages/regenerator-runtime/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,9 @@
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead of the
// polyfill unless it's the broken Firefox IteratorPrototype. See
// https://github.com/facebook/regenerator/issues/274 for more details.
var _n = NativeIteratorPrototype[iteratorSymbol].call(NativeIteratorPrototype);
if (!_n || !_n.next || _n.next.name !== 'LegacyIteratorNext') {
IteratorPrototype = NativeIteratorPrototype;
}
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}

var Gp = GeneratorFunctionPrototype.prototype =
Expand Down Expand Up @@ -396,6 +392,15 @@

Gp[toStringTagSymbol] = "Generator";

// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};

Gp.toString = function() {
return "[object Generator]";
};
Expand Down