fix(zone.js): remove unused Promise overwritten setter logic (#36851)
In the early Zone.js versions (< 0.10.3), `ZoneAwarePromise` did not support `Symbol.species`, so when user used a 3rd party `Promise` such as `es6-promise`, and try to load the promise library after import of `zone.js`, the loading promise library will overwrite the patched `Promise` from `zone.js` and will break `Promise` semantics with respect to `zone.js`. Starting with `zone.js` 0.10.3, `Symbol.species` is supported therefore this will not longer be an issue. (https://github.com//pull/34533) Before 0.10.3, the logic in zone.js tried to handle the case in the wrong way. It did so by overriding the descriptor of `global.Promise`, to allow the 3rd party libraries to override native `Promise` instead of `ZoneAwarePromise`. This is not the correct solution, and since the `Promise.species` is now supported, the 3rd party solution of overriding `global.Promise` is no longer needed. PR removes the wrong work around logic. (This will improve the bundle size.) PR Close #36851
This commit is contained in:

committed by
Misko Hevery

parent
9b8eb42354
commit
c909e731d7
@ -340,7 +340,6 @@ interface _ZonePrivate {
|
||||
patchEventTarget: (global: any, apis: any[], options?: any) => boolean[];
|
||||
patchOnProperties: (obj: any, properties: string[]|null, prototype?: any) => void;
|
||||
patchThen: (ctro: Function) => void;
|
||||
setNativePromise: (nativePromise: any) => void;
|
||||
patchMethod:
|
||||
(target: any, name: string,
|
||||
patchFn: (delegate: Function, delegateName: string, name: string) =>
|
||||
@ -1419,14 +1418,6 @@ const Zone: ZoneType = (function(global: any) {
|
||||
bindArguments: () => [],
|
||||
patchThen: () => noop,
|
||||
patchMacroTask: () => noop,
|
||||
setNativePromise: (NativePromise: any) => {
|
||||
// sometimes NativePromise.resolve static function
|
||||
// is not ready yet, (such as core-js/es6.promise)
|
||||
// so we need to check here.
|
||||
if (NativePromise && typeof NativePromise.resolve === 'function') {
|
||||
nativeMicroTaskQueuePromise = NativePromise.resolve(0);
|
||||
}
|
||||
},
|
||||
patchEventPrototype: () => noop,
|
||||
isIEOrEdge: () => false,
|
||||
getGlobalObjects: () => undefined,
|
||||
|
Reference in New Issue
Block a user