@@ -683,7 +683,7 @@ const Zone: ZoneType = (function(global: any) {
683
683
static __symbol__ : ( name : string ) => string = __symbol__ ;
684
684
685
685
static assertZonePatched ( ) {
686
- if ( patchLoaded && global [ 'Promise' ] !== patchedPromise ) {
686
+ if ( global [ 'Promise' ] !== patchedPromise ) {
687
687
throw new Error (
688
688
'Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' +
689
689
'has been overwritten.\n' +
@@ -717,39 +717,17 @@ const Zone: ZoneType = (function(global: any) {
717
717
_mode = newMode ;
718
718
}
719
719
720
- static __load_patch ( name : string , fn : _PatchFn , preload = false ) : void {
720
+ static __load_patch ( name : string , fn : _PatchFn ) : void {
721
721
if ( patches . hasOwnProperty ( name ) ) {
722
722
throw Error ( 'Already loaded patch: ' + name ) ;
723
723
} else if ( ! global [ '__Zone_disable_' + name ] ) {
724
724
const perfName = 'Zone:' + name ;
725
725
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 ) ;
733
727
performanceMeasure ( perfName , perfName ) ;
734
728
}
735
729
}
736
730
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
-
753
731
static __register_patched_delegate (
754
732
proto : any , property : string , origin : any , isPropertyDesc = false ) {
755
733
if ( ! isPropertyDesc ) {
@@ -772,7 +750,7 @@ const Zone: ZoneType = (function(global: any) {
772
750
}
773
751
774
752
static __reloadAll ( ) {
775
- if ( patchLoaded ) {
753
+ if ( monkeyPatched ) {
776
754
return ;
777
755
}
778
756
delegates . forEach ( delegate => {
@@ -782,11 +760,11 @@ const Zone: ZoneType = (function(global: any) {
782
760
delegate . proto [ delegate . property ] = delegate . patched ;
783
761
}
784
762
} ) ;
785
- patchLoaded = true ;
763
+ monkeyPatched = true ;
786
764
}
787
765
788
766
static __unloadAll ( ) {
789
- if ( ! patchLoaded ) {
767
+ if ( ! monkeyPatched ) {
790
768
return ;
791
769
}
792
770
delegates . forEach ( delegate => {
@@ -796,7 +774,7 @@ const Zone: ZoneType = (function(global: any) {
796
774
delegate . proto [ delegate . property ] = delegate . origin ;
797
775
}
798
776
} ) ;
799
- patchLoaded = false ;
777
+ monkeyPatched = false ;
800
778
}
801
779
802
780
public get parent ( ) : AmbientZone | null {
@@ -856,7 +834,7 @@ const Zone: ZoneType = (function(global: any) {
856
834
public run ( callback : Function , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : any ;
857
835
public run < T > (
858
836
callback : ( ...args : any [ ] ) => T , applyThis ?: any , applyArgs ?: any [ ] , source ?: string ) : T {
859
- if ( ! patchLoaded && _mode === 'lazy' ) {
837
+ if ( ! monkeyPatched && _mode === 'lazy' ) {
860
838
Zone . __reloadAll ( ) ;
861
839
}
862
840
_currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -874,7 +852,7 @@ const Zone: ZoneType = (function(global: any) {
874
852
public runGuarded < T > (
875
853
callback : ( ...args : any [ ] ) => T , applyThis : any = null , applyArgs ?: any [ ] ,
876
854
source ?: string ) {
877
- if ( ! patchLoaded && _mode === 'lazy' ) {
855
+ if ( ! monkeyPatched && _mode === 'lazy' ) {
878
856
Zone . __reloadAll ( ) ;
879
857
}
880
858
_currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -914,7 +892,7 @@ const Zone: ZoneType = (function(global: any) {
914
892
task . runCount ++ ;
915
893
const previousTask = _currentTask ;
916
894
_currentTask = task ;
917
- if ( ! patchLoaded && _mode === 'lazy' ) {
895
+ if ( ! monkeyPatched && _mode === 'lazy' ) {
918
896
Zone . __reloadAll ( ) ;
919
897
}
920
898
_currentZoneFrame = { parent : _currentZoneFrame , zone : this } ;
@@ -1451,7 +1429,7 @@ const Zone: ZoneType = (function(global: any) {
1451
1429
let patchedPromise : any ;
1452
1430
const delegates :
1453
1431
{ proto : any , property : string , patched : any , origin : any , isPropertyDesc : boolean } [ ] = [ ] ;
1454
- let patchLoaded = false ;
1432
+ let monkeyPatched = true ;
1455
1433
const _api : _ZonePrivate = {
1456
1434
symbol : __symbol__ ,
1457
1435
currentZoneFrame : ( ) => _currentZoneFrame ,
@@ -1472,7 +1450,8 @@ const Zone: ZoneType = (function(global: any) {
1472
1450
nativeMicroTaskQueuePromise = NativePromise . resolve ( 0 ) ;
1473
1451
}
1474
1452
} ,
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 )
1476
1455
} ;
1477
1456
let _currentZoneFrame : _ZoneFrame = { parent : null , zone : new Zone ( null , null ) } ;
1478
1457
let _currentTask : Task | null = null ;
0 commit comments