@@ -683,7 +683,7 @@ const Zone: ZoneType = (function(global: any) {
683683 static __symbol__ : ( name : string ) => string = __symbol__ ;
684684
685685 static assertZonePatched ( ) {
686- if ( patchLoaded && global [ 'Promise' ] !== patchedPromise ) {
686+ if ( global [ 'Promise' ] !== patchedPromise ) {
687687 throw new Error (
688688 'Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' +
689689 'has been overwritten.\n' +
@@ -717,39 +717,17 @@ const Zone: ZoneType = (function(global: any) {
717717 _mode = newMode ;
718718 }
719719
720- static __load_patch ( name : string , fn : _PatchFn , preload = false ) : void {
720+ static __load_patch ( name : string , fn : _PatchFn ) : void {
721721 if ( patches . hasOwnProperty ( name ) ) {
722722 throw Error ( 'Already loaded patch: ' + name ) ;
723723 } else if ( ! global [ '__Zone_disable_' + name ] ) {
724724 const perfName = 'Zone:' + name ;
725725 mark ( perfName ) ;
726- if ( _mode === 'normal' || preload ) {
727- patches [ name ] = fn ( global , Zone , _api ) ;
728- } else {
729- patches [ name ] = function ( ) {
730- return fn ( global , Zone , _api ) ;
731- } ;
732- }
726+ patches [ name ] = fn ( global , Zone , _api ) ;
733727 performanceMeasure ( perfName , perfName ) ;
734728 }
735729 }
736730
737- static __load ( ) {
738- if ( patchLoaded ) {
739- return ;
740- }
741- Object . keys ( patches ) . forEach ( key => {
742- const loadPatchFn = patches [ key ] ;
743- if ( typeof loadPatchFn === 'function' ) {
744- const r = loadPatchFn ( ) ;
745- if ( key === 'ZoneAwarePromise' ) {
746- patchedPromise = r ;
747- }
748- }
749- } ) ;
750- patchLoaded = true ;
751- }
752-
753731 static __register_patched_delegate (
754732 proto : any , property : string , origin : any , isPropertyDesc = false ) {
755733 if ( ! isPropertyDesc ) {
@@ -772,7 +750,7 @@ const Zone: ZoneType = (function(global: any) {
772750 }
773751
774752 static __reloadAll ( ) {
775- if ( patchLoaded ) {
753+ if ( monkeyPatched ) {
776754 return ;
777755 }
778756 delegates . forEach ( delegate => {
@@ -782,11 +760,11 @@ const Zone: ZoneType = (function(global: any) {
782760 delegate . proto [ delegate . property ] = delegate . patched ;
783761 }
784762 } ) ;
785- patchLoaded = true ;
763+ monkeyPatched = true ;
786764 }
787765
788766 static __unloadAll ( ) {
789- if ( ! patchLoaded ) {
767+ if ( ! monkeyPatched ) {
790768 return ;
791769 }
792770 delegates . forEach ( delegate => {
@@ -796,7 +774,7 @@ const Zone: ZoneType = (function(global: any) {
796774 delegate . proto [ delegate . property ] = delegate . origin ;
797775 }
798776 } ) ;
799- patchLoaded = false ;
777+ monkeyPatched = false ;
800778 }
801779
802780 public get parent ( ) : AmbientZone | null {
@@ -856,7 +834,7 @@ const Zone: ZoneType = (function(global: any) {
856834 public run ( callback : Function , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : any ;
857835 public run < T > (
858836 callback : ( ...args : any [ ] ) => T , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : T {
859- if ( ! patchLoaded && _mode === 'lazy' ) {
837+ if ( ! monkeyPatched && _mode === 'lazy' ) {
860838 Zone . __reloadAll ( ) ;
861839 }
862840 _currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -874,7 +852,7 @@ const Zone: ZoneType = (function(global: any) {
874852 public runGuarded < T > (
875853 callback : ( ...args : any [ ] ) => T , applyThis : any = null , applyArgs ?: any [ ] ,
876854 source ?: string ) {
877- if ( ! patchLoaded && _mode === 'lazy' ) {
855+ if ( ! monkeyPatched && _mode === 'lazy' ) {
878856 Zone . __reloadAll ( ) ;
879857 }
880858 _currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -914,7 +892,7 @@ const Zone: ZoneType = (function(global: any) {
914892 task . runCount ++ ;
915893 const previousTask = _currentTask ;
916894 _currentTask = task ;
917- if ( ! patchLoaded && _mode === 'lazy' ) {
895+ if ( ! monkeyPatched && _mode === 'lazy' ) {
918896 Zone . __reloadAll ( ) ;
919897 }
920898 _currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -1451,7 +1429,7 @@ const Zone: ZoneType = (function(global: any) {
14511429 let patchedPromise : any ;
14521430 const delegates :
14531431 { proto : any , property : string , patched : any , origin : any , isPropertyDesc : boolean } [ ] = [ ] ;
1454- let patchLoaded = false ;
1432+ let monkeyPatched = true ;
14551433 const _api : _ZonePrivate = {
14561434 symbol : __symbol__ ,
14571435 currentZoneFrame : ( ) => _currentZoneFrame ,
@@ -1472,7 +1450,8 @@ const Zone: ZoneType = (function(global: any) {
14721450 nativeMicroTaskQueuePromise = NativePromise . resolve ( 0 ) ;
14731451 }
14741452 } ,
1475- attachOriginToPatched : ( patchedTarget : any , prop : string , original : any ) => noop
1453+ attachOriginToPatched : ( patchedTarget : any , prop : string , original : any ) =>
1454+ Zone . __register_patched_delegate ( patchedTarget , prop , original )
14761455 } ;
14771456 let _currentZoneFrame : _ZoneFrame = { parent : null , zone : new Zone ( null , null ) } ;
14781457 let _currentTask : Task | null = null ;
0 commit comments