Skip to content

Commit

Permalink
avoid Promise.resolve in the main Promise feature detection
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed May 3, 2021
1 parent 5623fa3 commit afc66bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var FORCED = isForced(PROMISE, function () {
// https://github.com/zloirock/core-js/issues/679
if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
// Detect correctness of subclassing with @@species support
var promise = PromiseConstructor.resolve(1);
var promise = new PromiseConstructor(function (resolve) { resolve(1); });
var FakePromise = function (exec) {
exec(function () { /* empty */ }, function () { /* empty */ });
};
Expand Down
8 changes: 4 additions & 4 deletions tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var DESCRIPTORS_SUPPORT = function () {
};

var PROMISES_SUPPORT = function () {
var promise = Promise.resolve(1);
var promise = new Promise(function (resolve) { resolve(1); });
var empty = function () { /* empty */ };
var FakePromise = (promise.constructor = {})[Symbol.species] = function (exec) {
exec(empty, empty);
};

return (IS_NODE || typeof PromiseRejectionEvent == 'function')
&& promise.then(empty) instanceof FakePromise
&& V8_VERSION !== 66;
return promise.then(empty) instanceof FakePromise
&& V8_VERSION !== 66
&& (IS_NODE || typeof PromiseRejectionEvent == 'function');
};

var SYMBOLS_SUPPORT = function () {
Expand Down

0 comments on commit afc66bc

Please sign in to comment.