diff --git a/CHANGELOG.md b/CHANGELOG.md index 8132be5344cc..14d5cda9710d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog ##### Unreleased - Added a workaround of WebKit ~ iOS 10.3 Safari `Promise` instantiation bug, [#932](https://github.com/zloirock/core-js/issues/932) +- `Promise#then` of incorrect native `Promise` implementations with correct subclassing no longer wrapped ##### 3.11.1 - 2021.04.28 - Made `instanceof Promise` and `.constructor === Promise` work with polyfilled `Promise` for all native promise-based APIs diff --git a/packages/core-js/modules/es.promise.js b/packages/core-js/modules/es.promise.js index 7fed1200a004..0b8baf30fdee 100644 --- a/packages/core-js/modules/es.promise.js +++ b/packages/core-js/modules/es.promise.js @@ -49,6 +49,7 @@ var FULFILLED = 1; var REJECTED = 2; var HANDLED = 1; var UNHANDLED = 2; +var SUBCLASSING = false; var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; var FORCED = isForced(PROMISE, function () { @@ -74,7 +75,7 @@ var FORCED = isForced(PROMISE, function () { }; var constructor = promise.constructor = {}; constructor[SPECIES] = FakePromise; - return !(promise.then(function () { /* empty */ }) instanceof FakePromise); + return !(SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise); }); var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) { @@ -288,7 +289,7 @@ if (FORCED) { nativeThen = NativePromisePrototype.then; // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs - redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { + if (!SUBCLASSING) redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { var that = this; return new PromiseConstructor(function (resolve, reject) { nativeThen.call(that, resolve, reject);