diff --git a/packages/regenerator-runtime/runtime.js b/packages/regenerator-runtime/runtime.js index 15fdacce8..5cd995ff5 100644 --- a/packages/regenerator-runtime/runtime.js +++ b/packages/regenerator-runtime/runtime.js @@ -392,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]"; };