@@ -643,6 +643,7 @@ const Zone: ZoneType = (function(global: any) {
643
643
performance && performance [ 'measure' ] && performance [ 'measure' ] ( name , label ) ;
644
644
}
645
645
mark ( 'Zone' ) ;
646
+ const checkDuplicate = global [ ( '__zone_symbol__forceDuplicateZoneCheck' ) ] === true ;
646
647
if ( global [ 'Zone' ] ) {
647
648
// if global['Zone'] already exists (maybe zone.js was already loaded or
648
649
// some other lib also registered a global object named Zone), we may need
@@ -653,8 +654,7 @@ const Zone: ZoneType = (function(global: any) {
653
654
// but when user load page2 again, error occurs because global['Zone'] already exists.
654
655
// so we add a flag to let user choose whether to throw this error or not.
655
656
// By default, if existing Zone is from zone.js, we will not throw the error.
656
- if ( global [ ( '__zone_symbol__forceDuplicateZoneCheck' ) ] === true ||
657
- typeof global [ 'Zone' ] . __symbol__ !== 'function' ) {
657
+ if ( checkDuplicate || typeof global [ 'Zone' ] . __symbol__ !== 'function' ) {
658
658
throw new Error ( 'Zone already loaded.' ) ;
659
659
} else {
660
660
return global [ 'Zone' ] ;
@@ -693,7 +693,9 @@ const Zone: ZoneType = (function(global: any) {
693
693
694
694
static __load_patch ( name : string , fn : _PatchFn ) : void {
695
695
if ( patches . hasOwnProperty ( name ) ) {
696
- throw Error ( 'Already loaded patch: ' + name ) ;
696
+ if ( checkDuplicate ) {
697
+ throw Error ( 'Already loaded patch: ' + name ) ;
698
+ }
697
699
} else if ( ! global [ '__Zone_disable_' + name ] ) {
698
700
const perfName = 'Zone:' + name ;
699
701
mark ( perfName ) ;
@@ -1364,4 +1366,4 @@ const Zone: ZoneType = (function(global: any) {
1364
1366
1365
1367
performanceMeasure ( 'Zone' , 'Zone' ) ;
1366
1368
return global [ 'Zone' ] = Zone ;
1367
- } ) ( typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global ) ;
1369
+ } ) ( typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global ) ;
0 commit comments