feat(zone): upgrade to zone.js@0.6.21

This commit is contained in:
Misko Hevery
2016-09-10 09:16:03 -07:00
committed by Igor Minar
parent c9513b713a
commit 051a6ebe12
6 changed files with 60 additions and 62 deletions

View File

@ -35,62 +35,61 @@ export class NgZoneImpl {
this.setMacrotask = setMacrotask;
this.onError = onError;
if (Zone) {
this.outer = this.inner = Zone.current;
if ((Zone as any /** TODO #9100 */)['wtfZoneSpec']) {
this.inner = this.inner.fork((Zone as any /** TODO #9100 */)['wtfZoneSpec']);
}
if (trace && (Zone as any /** TODO #9100 */)['longStackTraceZoneSpec']) {
this.inner = this.inner.fork((Zone as any /** TODO #9100 */)['longStackTraceZoneSpec']);
}
this.inner = this.inner.fork({
name: 'angular',
properties: <any>{'isAngularZone': true},
onInvokeTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task,
applyThis: any, applyArgs: any): any => {
try {
this.onEnter();
return delegate.invokeTask(target, task, applyThis, applyArgs);
} finally {
this.onLeave();
}
},
onInvoke: (delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function,
applyThis: any, applyArgs: any[], source: string): any => {
try {
this.onEnter();
return delegate.invoke(target, callback, applyThis, applyArgs, source);
} finally {
this.onLeave();
}
},
onHasTask:
(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => {
delegate.hasTask(target, hasTaskState);
if (current == target) {
// We are only interested in hasTask events which originate from our zone
// (A child hasTask event is not interesting to us)
if (hasTaskState.change == 'microTask') {
this.setMicrotask(hasTaskState.microTask);
} else if (hasTaskState.change == 'macroTask') {
this.setMacrotask(hasTaskState.macroTask);
}
}
},
onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any):
boolean => {
delegate.handleError(target, error);
this.onError(error);
return false;
}
});
} else {
throw new Error('Angular requires Zone.js polyfill.');
if (typeof Zone == 'undefined') {
throw new Error('Angular requires Zone.js prolyfill.');
}
Zone.assertZonePatched();
this.outer = this.inner = Zone.current;
if ((Zone as any)['wtfZoneSpec']) {
this.inner = this.inner.fork((Zone as any)['wtfZoneSpec']);
}
if (trace && (Zone as any)['longStackTraceZoneSpec']) {
this.inner = this.inner.fork((Zone as any)['longStackTraceZoneSpec']);
}
this.inner = this.inner.fork({
name: 'angular',
properties: <any>{'isAngularZone': true},
onInvokeTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task,
applyThis: any, applyArgs: any): any => {
try {
this.onEnter();
return delegate.invokeTask(target, task, applyThis, applyArgs);
} finally {
this.onLeave();
}
},
onInvoke: (delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function,
applyThis: any, applyArgs: any[], source: string): any => {
try {
this.onEnter();
return delegate.invoke(target, callback, applyThis, applyArgs, source);
} finally {
this.onLeave();
}
},
onHasTask:
(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => {
delegate.hasTask(target, hasTaskState);
if (current === target) {
// We are only interested in hasTask events which originate from our zone
// (A child hasTask event is not interesting to us)
if (hasTaskState.change == 'microTask') {
this.setMicrotask(hasTaskState.microTask);
} else if (hasTaskState.change == 'macroTask') {
this.setMacrotask(hasTaskState.macroTask);
}
}
},
onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): boolean => {
delegate.handleError(target, error);
this.onError(error);
return false;
}
});
}
runInner(fn: () => any): any { return this.inner.run(fn); };