Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/zone.js/lib/common/promise.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {patchMethod} from './utils';

/**
* @license
* Copyright Google Inc. All Rights Reserved.
Expand Down Expand Up @@ -500,8 +502,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
api.patchThen = patchThen;

function zoneify(fn: Function) {
return function(this: unknown) {
let resultPromise = fn.apply(this, arguments);
return function(self: any, args: any[]) {
let resultPromise = fn.apply(self, args);
if (resultPromise instanceof ZoneAwarePromise) {
return resultPromise;
}
Expand All @@ -515,11 +517,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr

if (NativePromise) {
patchThen(NativePromise);
const fetch = global['fetch'];
if (typeof fetch == 'function') {
global[api.symbol('fetch')] = fetch;
global['fetch'] = zoneify(fetch);
}
patchMethod(global, 'fetch', delegate => zoneify(delegate));
}

// This is not part of public API, but it is useful for tests, so we expose it.
Expand Down