Skip to content

Commit f9acb92

Browse files
committed
Generalize recursion fix for all polyfills
1 parent 4788318 commit f9acb92

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
416416
if (onFulfilled) { onFulfilled = onFulfilled.bind(self); }
417417
if (onRejected) { onRejected = onRejected.bind(self); }
418418

419-
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
420-
var selfPromise = ('_state' in self) ?
419+
// Cast self into a Promise to avoid polyfills recursively defining `then`.
420+
var selfPromise = (Promise.toString().indexOf('[native code]') === -1) ?
421421
Worker.convert(Object.assign({}, self), Promise.prototype) : self;
422422

423423
// Update progress while queuing, calling, and resolving `then`.
@@ -442,8 +442,8 @@ Worker.prototype.thenCore = function thenCore(onFulfilled, onRejected) {
442442
if (onFulfilled) { onFulfilled = onFulfilled.bind(self); }
443443
if (onRejected) { onRejected = onRejected.bind(self); }
444444

445-
// Cast self into a Promise to avoid es6-promise recursively defining `then`.
446-
var selfPromise = ('_state' in self) ?
445+
// Cast self into a Promise to avoid polyfills recursively defining `then`.
446+
var selfPromise = (Promise.toString().indexOf('[native code]') === -1) ?
447447
Worker.convert(Object.assign({}, self), Promise.prototype) : self;
448448

449449
// Return the promise, after casting it into a Worker and preserving props.

0 commit comments

Comments
 (0)