@@ -35,62 +35,61 @@ export class NgZoneImpl {
3535 this . setMacrotask = setMacrotask ;
3636 this . onError = onError ;
3737
38- if ( Zone ) {
39- this . outer = this . inner = Zone . current ;
40- if ( ( Zone as any /** TODO #9100 */ ) [ 'wtfZoneSpec' ] ) {
41- this . inner = this . inner . fork ( ( Zone as any /** TODO #9100 */ ) [ 'wtfZoneSpec' ] ) ;
42- }
43- if ( trace && ( Zone as any /** TODO #9100 */ ) [ 'longStackTraceZoneSpec' ] ) {
44- this . inner = this . inner . fork ( ( Zone as any /** TODO #9100 */ ) [ 'longStackTraceZoneSpec' ] ) ;
45- }
46- this . inner = this . inner . fork ( {
47- name : 'angular' ,
48- properties : < any > { 'isAngularZone' : true } ,
49- onInvokeTask : ( delegate : ZoneDelegate , current : Zone , target : Zone , task : Task ,
50- applyThis : any , applyArgs : any ) : any => {
51- try {
52- this . onEnter ( ) ;
53- return delegate . invokeTask ( target , task , applyThis , applyArgs ) ;
54- } finally {
55- this . onLeave ( ) ;
56- }
57- } ,
38+ if ( typeof Zone == 'undefined' ) {
39+ throw new Error ( 'Angular requires Zone.js prolyfill.' ) ;
40+ }
41+ Zone . assertZonePatched ( ) ;
42+ this . outer = this . inner = Zone . current ;
43+ if ( ( Zone as any ) [ 'wtfZoneSpec' ] ) {
44+ this . inner = this . inner . fork ( ( Zone as any ) [ 'wtfZoneSpec' ] ) ;
45+ }
46+ if ( trace && ( Zone as any ) [ 'longStackTraceZoneSpec' ] ) {
47+ this . inner = this . inner . fork ( ( Zone as any ) [ 'longStackTraceZoneSpec' ] ) ;
48+ }
49+ this . inner = this . inner . fork ( {
50+ name : 'angular' ,
51+ properties : < any > { 'isAngularZone' : true } ,
52+ onInvokeTask : ( delegate : ZoneDelegate , current : Zone , target : Zone , task : Task ,
53+ applyThis : any , applyArgs : any ) : any => {
54+ try {
55+ this . onEnter ( ) ;
56+ return delegate . invokeTask ( target , task , applyThis , applyArgs ) ;
57+ } finally {
58+ this . onLeave ( ) ;
59+ }
60+ } ,
5861
5962
60- onInvoke : ( delegate : ZoneDelegate , current : Zone , target : Zone , callback : Function ,
61- applyThis : any , applyArgs : any [ ] , source : string ) : any => {
62- try {
63- this . onEnter ( ) ;
64- return delegate . invoke ( target , callback , applyThis , applyArgs , source ) ;
65- } finally {
66- this . onLeave ( ) ;
67- }
68- } ,
63+ onInvoke : ( delegate : ZoneDelegate , current : Zone , target : Zone , callback : Function ,
64+ applyThis : any , applyArgs : any [ ] , source : string ) : any => {
65+ try {
66+ this . onEnter ( ) ;
67+ return delegate . invoke ( target , callback , applyThis , applyArgs , source ) ;
68+ } finally {
69+ this . onLeave ( ) ;
70+ }
71+ } ,
6972
70- onHasTask :
71- ( delegate : ZoneDelegate , current : Zone , target : Zone , hasTaskState : HasTaskState ) => {
72- delegate . hasTask ( target , hasTaskState ) ;
73- if ( current == target ) {
74- // We are only interested in hasTask events which originate from our zone
75- // (A child hasTask event is not interesting to us)
76- if ( hasTaskState . change == 'microTask' ) {
77- this . setMicrotask ( hasTaskState . microTask ) ;
78- } else if ( hasTaskState . change == 'macroTask' ) {
79- this . setMacrotask ( hasTaskState . macroTask ) ;
80- }
73+ onHasTask :
74+ ( delegate : ZoneDelegate , current : Zone , target : Zone , hasTaskState : HasTaskState ) => {
75+ delegate . hasTask ( target , hasTaskState ) ;
76+ if ( current === target ) {
77+ // We are only interested in hasTask events which originate from our zone
78+ // (A child hasTask event is not interesting to us)
79+ if ( hasTaskState . change == 'microTask' ) {
80+ this . setMicrotask ( hasTaskState . microTask ) ;
81+ } else if ( hasTaskState . change == 'macroTask' ) {
82+ this . setMacrotask ( hasTaskState . macroTask ) ;
8183 }
82- } ,
84+ }
85+ } ,
8386
84- onHandleError : ( delegate : ZoneDelegate , current : Zone , target : Zone , error : any ) :
85- boolean => {
86- delegate . handleError ( target , error ) ;
87- this . onError ( error ) ;
88- return false ;
89- }
90- } ) ;
91- } else {
92- throw new Error ( 'Angular requires Zone.js polyfill.' ) ;
93- }
87+ onHandleError : ( delegate : ZoneDelegate , current : Zone , target : Zone , error : any ) : boolean => {
88+ delegate . handleError ( target , error ) ;
89+ this . onError ( error ) ;
90+ return false ;
91+ }
92+ } ) ;
9493 }
9594
9695 runInner ( fn : ( ) => any ) : any { return this . inner . run ( fn ) ; } ;
0 commit comments