Skip to content

Commit

Permalink
wrap fetch for prevent problems like #178, #332, #371
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jan 23, 2019
1 parent 2a005ab commit 96d5372
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var PromiseConstructor = global[PROMISE];
var TypeError = global.TypeError;
var document = global.document;
var process = global.process;
var $fetch = global.fetch;
var versions = process && process.versions;
var v8 = versions && versions.v8 || '';
var newPromiseCapability = newPromiseCapabilityModule.f;
Expand Down Expand Up @@ -263,6 +264,14 @@ if (FORCED) {
? new OwnPromiseCapability(C)
: newGenericPromiseCapability(C);
};

// wrap fetch result
if (!IS_PURE && typeof $fetch == 'function') $export({ global: true, forced: true }, {
// eslint-disable-next-line no-unused-vars
fetch: function fetch(input) {
return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
}
});
}

$export({ global: true, wrap: true, forced: FORCED }, { Promise: PromiseConstructor });
Expand Down

0 comments on commit 96d5372

Please sign in to comment.