Skip to content

Commit

Permalink
change the order of Promise feature detection
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed May 3, 2021
1 parent e280a0a commit 5623fa3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,10 @@ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;

var FORCED = isForced(PROMISE, function () {
var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
if (!GLOBAL_CORE_JS_PROMISE) {
// V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
// We can't detect it synchronously, so just check versions
if (V8_VERSION === 66) return true;
// Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
if (!IS_NODE && !NATIVE_REJECTION_EVENT) return true;
}
// V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
// We can't detect it synchronously, so just check versions
if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
// We need Promise#finally in the pure version for preventing prototype pollution
if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
// We can't use @@species feature detection in V8 since it causes
Expand All @@ -75,7 +71,10 @@ var FORCED = isForced(PROMISE, function () {
};
var constructor = promise.constructor = {};
constructor[SPECIES] = FakePromise;
return !(SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise);
SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
if (!SUBCLASSING) return true;
// Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
return !GLOBAL_CORE_JS_PROMISE && !IS_NODE && !NATIVE_REJECTION_EVENT;
});

var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
Expand Down

0 comments on commit 5623fa3

Please sign in to comment.