From ea4de31e4a8151fab67dfa7485b2ac5ede4f8eb3 Mon Sep 17 00:00:00 2001 From: Ray Di Ciaccio Date: Fri, 28 Apr 2017 10:45:20 -0400 Subject: [PATCH] Resolve yield * issues for Firefox < 45 (#278) * Detect when Firefox is trying to use the broken, alternative Iterator form and don't use it. Polyfill instead. * Fix @@iterator function call for generators, so that the generator itself is returned. --- packages/regenerator-runtime/runtime.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/regenerator-runtime/runtime.js b/packages/regenerator-runtime/runtime.js index d359834d1..5b08c4d34 100644 --- a/packages/regenerator-runtime/runtime.js +++ b/packages/regenerator-runtime/runtime.js @@ -416,6 +416,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]"; };