@@ -721,67 +721,90 @@ const Zone: ZoneType = (function(global: any) {
721
721
722
722
private _forkDlgt : ZoneDelegate ;
723
723
private _forkZS : ZoneSpec ;
724
+ private _forkCurrZone : Zone ;
724
725
725
726
private _interceptDlgt : ZoneDelegate ;
726
727
private _interceptZS : ZoneSpec ;
728
+ private _interceptCurrZone : Zone ;
727
729
728
730
private _invokeDlgt : ZoneDelegate ;
729
731
private _invokeZS : ZoneSpec ;
732
+ private _invokeCurrZone : Zone ;
730
733
731
734
private _handleErrorDlgt : ZoneDelegate ;
732
735
private _handleErrorZS : ZoneSpec ;
736
+ private _handleErrorCurrZone : Zone ;
733
737
734
738
private _scheduleTaskDlgt : ZoneDelegate ;
735
739
private _scheduleTaskZS : ZoneSpec ;
740
+ private _scheduleTaskCurrZone : Zone ;
736
741
737
742
private _invokeTaskDlgt : ZoneDelegate ;
738
743
private _invokeTaskZS : ZoneSpec ;
744
+ private _invokeTaskCurrZone : Zone ;
739
745
740
746
private _cancelTaskDlgt : ZoneDelegate ;
741
747
private _cancelTaskZS : ZoneSpec ;
748
+ private _cancelTaskCurrZone : Zone ;
742
749
743
750
private _hasTaskDlgt : ZoneDelegate ;
744
751
private _hasTaskZS : ZoneSpec ;
752
+ private _hasTaskCurrZone : Zone ;
745
753
746
754
constructor ( zone : Zone , parentDelegate : ZoneDelegate , zoneSpec : ZoneSpec ) {
747
755
this . zone = zone ;
748
756
this . _parentDelegate = parentDelegate ;
749
757
750
758
this . _forkZS = zoneSpec && ( zoneSpec && zoneSpec . onFork ? zoneSpec : parentDelegate . _forkZS ) ;
751
759
this . _forkDlgt = zoneSpec && ( zoneSpec . onFork ? parentDelegate : parentDelegate . _forkDlgt ) ;
760
+ this . _forkCurrZone = zoneSpec && ( zoneSpec . onFork ? this . zone : parentDelegate . zone ) ;
752
761
753
762
this . _interceptZS =
754
763
zoneSpec && ( zoneSpec . onIntercept ? zoneSpec : parentDelegate . _interceptZS ) ;
755
764
this . _interceptDlgt =
756
765
zoneSpec && ( zoneSpec . onIntercept ? parentDelegate : parentDelegate . _interceptDlgt ) ;
766
+ this . _interceptCurrZone =
767
+ zoneSpec && ( zoneSpec . onIntercept ? this . zone : parentDelegate . zone ) ;
757
768
758
769
this . _invokeZS = zoneSpec && ( zoneSpec . onInvoke ? zoneSpec : parentDelegate . _invokeZS ) ;
759
770
this . _invokeDlgt =
760
771
zoneSpec && ( zoneSpec . onInvoke ? parentDelegate : parentDelegate . _invokeDlgt ) ;
772
+ this . _invokeCurrZone =
773
+ zoneSpec && ( zoneSpec . onInvoke ? this . zone : parentDelegate . zone ) ;
761
774
762
775
this . _handleErrorZS =
763
776
zoneSpec && ( zoneSpec . onHandleError ? zoneSpec : parentDelegate . _handleErrorZS ) ;
764
777
this . _handleErrorDlgt =
765
778
zoneSpec && ( zoneSpec . onHandleError ? parentDelegate : parentDelegate . _handleErrorDlgt ) ;
779
+ this . _handleErrorCurrZone =
780
+ zoneSpec && ( zoneSpec . onHandleError ? this . zone : parentDelegate . zone ) ;
766
781
767
782
this . _scheduleTaskZS =
768
783
zoneSpec && ( zoneSpec . onScheduleTask ? zoneSpec : parentDelegate . _scheduleTaskZS ) ;
769
784
this . _scheduleTaskDlgt =
770
785
zoneSpec && ( zoneSpec . onScheduleTask ? parentDelegate : parentDelegate . _scheduleTaskDlgt ) ;
786
+ this . _scheduleTaskCurrZone =
787
+ zoneSpec && ( zoneSpec . onScheduleTask ? this . zone : parentDelegate . zone ) ;
771
788
772
789
this . _invokeTaskZS =
773
790
zoneSpec && ( zoneSpec . onInvokeTask ? zoneSpec : parentDelegate . _invokeTaskZS ) ;
774
791
this . _invokeTaskDlgt =
775
792
zoneSpec && ( zoneSpec . onInvokeTask ? parentDelegate : parentDelegate . _invokeTaskDlgt ) ;
793
+ this . _invokeTaskCurrZone =
794
+ zoneSpec && ( zoneSpec . onInvokeTask ? this . zone : parentDelegate . zone ) ;
776
795
777
796
this . _cancelTaskZS =
778
797
zoneSpec && ( zoneSpec . onCancelTask ? zoneSpec : parentDelegate . _cancelTaskZS ) ;
779
798
this . _cancelTaskDlgt =
780
799
zoneSpec && ( zoneSpec . onCancelTask ? parentDelegate : parentDelegate . _cancelTaskDlgt ) ;
800
+ this . _cancelTaskCurrZone =
801
+ zoneSpec && ( zoneSpec . onCancelTask ? this . zone : parentDelegate . zone ) ;
781
802
782
803
this . _hasTaskZS = zoneSpec && ( zoneSpec . onHasTask ? zoneSpec : parentDelegate . _hasTaskZS ) ;
783
804
this . _hasTaskDlgt =
784
805
zoneSpec && ( zoneSpec . onHasTask ? parentDelegate : parentDelegate . _hasTaskDlgt ) ;
806
+ this . _hasTaskCurrZone =
807
+ zoneSpec && ( zoneSpec . onHasTask ? this . zone : parentDelegate . zone ) ;
785
808
}
786
809
787
810
fork ( targetZone : Zone , zoneSpec : ZoneSpec ) : AmbientZone {
@@ -792,29 +815,29 @@ const Zone: ZoneType = (function(global: any) {
792
815
intercept ( targetZone : Zone , callback : Function , source : string ) : Function {
793
816
return this . _interceptZS ?
794
817
this . _interceptZS . onIntercept (
795
- this . _interceptDlgt , this . zone , targetZone , callback , source ) :
818
+ this . _interceptDlgt , this . _interceptCurrZone , targetZone , callback , source ) :
796
819
callback ;
797
820
}
798
821
799
822
invoke ( targetZone : Zone , callback : Function , applyThis : any , applyArgs : any [ ] , source : string ) :
800
823
any {
801
824
return this . _invokeZS ?
802
825
this . _invokeZS . onInvoke (
803
- this . _invokeDlgt , this . zone , targetZone , callback , applyThis , applyArgs , source ) :
826
+ this . _invokeDlgt , this . _invokeCurrZone , targetZone , callback , applyThis , applyArgs , source ) :
804
827
callback . apply ( applyThis , applyArgs ) ;
805
828
}
806
829
807
830
handleError ( targetZone : Zone , error : any ) : boolean {
808
831
return this . _handleErrorZS ?
809
- this . _handleErrorZS . onHandleError ( this . _handleErrorDlgt , this . zone , targetZone , error ) :
832
+ this . _handleErrorZS . onHandleError ( this . _handleErrorDlgt , this . _handleErrorCurrZone , targetZone , error ) :
810
833
true ;
811
834
}
812
835
813
836
scheduleTask ( targetZone : Zone , task : Task ) : Task {
814
837
try {
815
838
if ( this . _scheduleTaskZS ) {
816
839
return this . _scheduleTaskZS . onScheduleTask (
817
- this . _scheduleTaskDlgt , this . zone , targetZone , task ) ;
840
+ this . _scheduleTaskDlgt , this . _scheduleTaskCurrZone , targetZone , task ) ;
818
841
} else if ( task . scheduleFn ) {
819
842
task . scheduleFn ( task ) ;
820
843
} else if ( task . type == 'microTask' ) {
@@ -834,7 +857,7 @@ const Zone: ZoneType = (function(global: any) {
834
857
try {
835
858
return this . _invokeTaskZS ?
836
859
this . _invokeTaskZS . onInvokeTask (
837
- this . _invokeTaskDlgt , this . zone , targetZone , task , applyThis , applyArgs ) :
860
+ this . _invokeTaskDlgt , this . _invokeTaskCurrZone , targetZone , task , applyThis , applyArgs ) :
838
861
task . callback . apply ( applyThis , applyArgs ) ;
839
862
} finally {
840
863
if ( targetZone == this . zone && ( task . type != 'eventTask' ) &&
@@ -847,7 +870,7 @@ const Zone: ZoneType = (function(global: any) {
847
870
cancelTask ( targetZone : Zone , task : Task ) : any {
848
871
let value ;
849
872
if ( this . _cancelTaskZS ) {
850
- value = this . _cancelTaskZS . onCancelTask ( this . _cancelTaskDlgt , this . zone , targetZone , task ) ;
873
+ value = this . _cancelTaskZS . onCancelTask ( this . _cancelTaskDlgt , this . _cancelTaskCurrZone , targetZone , task ) ;
851
874
} else if ( ! task . cancelFn ) {
852
875
throw new Error ( 'Task does not support cancellation, or is already canceled.' ) ;
853
876
} else {
@@ -862,7 +885,7 @@ const Zone: ZoneType = (function(global: any) {
862
885
863
886
hasTask ( targetZone : Zone , isEmpty : HasTaskState ) {
864
887
return this . _hasTaskZS &&
865
- this . _hasTaskZS . onHasTask ( this . _hasTaskDlgt , this . zone , targetZone , isEmpty ) ;
888
+ this . _hasTaskZS . onHasTask ( this . _hasTaskDlgt , this . _hasTaskCurrZone , targetZone , isEmpty ) ;
866
889
}
867
890
868
891
private _updateTaskCount ( type : TaskType , count : number ) {
0 commit comments