Skip to content

Commit

Permalink
make instanceof Promise work for all native promise-based APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Apr 26, 2021
1 parent 869036f commit 02ed1bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Changelog
##### Unreleased
- Nothing
- Made `instanceof Promise` work with polyfilled `Promise` for all native promise-based APIs

##### 3.11.0 - 2021.04.22
- Added [accessible `Object#hasOwnProperty` stage 2 proposal](https://github.com/tc39/proposal-accessible-object-hasownproperty)
Expand Down
8 changes: 7 additions & 1 deletion packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var getBuiltIn = require('../internals/get-built-in');
var NativePromise = require('../internals/native-promise-constructor');
var redefine = require('../internals/redefine');
var redefineAll = require('../internals/redefine-all');
var setPrototypeOf = require('../internals/object-set-prototype-of');
var setToStringTag = require('../internals/set-to-string-tag');
var setSpecies = require('../internals/set-species');
var isObject = require('../internals/is-object');
Expand Down Expand Up @@ -295,7 +296,12 @@ if (FORCED) {
// https://github.com/zloirock/core-js/issues/640
}, { unsafe: true });

// wrap fetch result
// make `instanceof Promise` work for all native promise-based APIs
if (setPrototypeOf) {
setPrototypeOf(NativePromise.prototype, PromiseConstructor.prototype);
}

// wrap fetch result, TODO: drop it in `core-js@4` in favor of workaround above
if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {
// eslint-disable-next-line no-unused-vars -- required for `.length`
fetch: function fetch(input /* , init */) {
Expand Down

0 comments on commit 02ed1bd

Please sign in to comment.