@@ -38,6 +38,16 @@ export const FALSE_STR = 'false';
3838/** __zone_symbol__ string const */
3939export const ZONE_SYMBOL_PREFIX = '__zone_symbol__' ;
4040
41+ export function wrapWithCurrentZone < T extends Function > ( callback : T , source : string ) : T {
42+ return Zone . current . wrap ( callback , source ) ;
43+ }
44+
45+ export function scheduleMacroTaskWithCurrentZone (
46+ source : string , callback : Function , data : TaskData , customSchedule : ( task : Task ) => void ,
47+ customCancel : ( task : Task ) => void ) : MacroTask {
48+ return Zone . current . scheduleMacroTask ( source , callback , data , customSchedule , customCancel ) ;
49+ }
50+
4151// Hack since TypeScript isn't compiling this for a worker.
4252declare const WorkerGlobalScope : any ;
4353
@@ -52,7 +62,7 @@ const NULL_ON_PROP_VALUE: any[] = [null];
5262export function bindArguments ( args : any [ ] , source : string ) : any [ ] {
5363 for ( let i = args . length - 1 ; i >= 0 ; i -- ) {
5464 if ( typeof args [ i ] === 'function' ) {
55- args [ i ] = Zone . current . wrap ( args [ i ] , source + '_' + i ) ;
65+ args [ i ] = wrapWithCurrentZone ( args [ i ] , source + '_' + i ) ;
5666 }
5767 }
5868 return args ;
@@ -300,7 +310,7 @@ export function patchClass(className: string) {
300310 ObjectDefineProperty ( _global [ className ] . prototype , prop , {
301311 set : function ( fn ) {
302312 if ( typeof fn === 'function' ) {
303- this [ originalInstanceKey ] [ prop ] = Zone . current . wrap ( fn , className + '.' + prop ) ;
313+ this [ originalInstanceKey ] [ prop ] = wrapWithCurrentZone ( fn , className + '.' + prop ) ;
304314 // keep callback in wrapped function so we can
305315 // use it in Function.prototype.toString to return
306316 // the native one.
@@ -379,7 +389,8 @@ export function patchMacroTask(
379389 setNative = patchMethod ( obj , funcName , ( delegate : Function ) => function ( self : any , args : any [ ] ) {
380390 const meta = metaCreator ( self , args ) ;
381391 if ( meta . cbIdx >= 0 && typeof args [ meta . cbIdx ] === 'function' ) {
382- return Zone . current . scheduleMacroTask ( meta . name , args [ meta . cbIdx ] , meta , scheduleTask , null ) ;
392+ return scheduleMacroTaskWithCurrentZone (
393+ meta . name , args [ meta . cbIdx ] , meta , scheduleTask , null ) ;
383394 } else {
384395 // cause an error by calling it directly.
385396 return delegate . apply ( self , args ) ;
0 commit comments