Skip to content

Commit

Permalink
don't wrap Promise#then of incorrect native Promise implementatio…
Browse files Browse the repository at this point in the history
…ns with correct subclassing
  • Loading branch information
zloirock committed May 3, 2021
1 parent c78f69d commit e280a0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e280a0a

Please sign in to comment.