@@ -643,6 +643,7 @@ const Zone: ZoneType = (function(global: any) {
643643 performance && performance [ 'measure' ] && performance [ 'measure' ] ( name , label ) ;
644644 }
645645 mark ( 'Zone' ) ;
646+ const checkDuplicate = global [ ( '__zone_symbol__forceDuplicateZoneCheck' ) ] === true ;
646647 if ( global [ 'Zone' ] ) {
647648 // if global['Zone'] already exists (maybe zone.js was already loaded or
648649 // some other lib also registered a global object named Zone), we may need
@@ -653,8 +654,7 @@ const Zone: ZoneType = (function(global: any) {
653654 // but when user load page2 again, error occurs because global['Zone'] already exists.
654655 // so we add a flag to let user choose whether to throw this error or not.
655656 // 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' ) {
658658 throw new Error ( 'Zone already loaded.' ) ;
659659 } else {
660660 return global [ 'Zone' ] ;
@@ -693,7 +693,9 @@ const Zone: ZoneType = (function(global: any) {
693693
694694 static __load_patch ( name : string , fn : _PatchFn ) : void {
695695 if ( patches . hasOwnProperty ( name ) ) {
696- throw Error ( 'Already loaded patch: ' + name ) ;
696+ if ( checkDuplicate ) {
697+ throw Error ( 'Already loaded patch: ' + name ) ;
698+ }
697699 } else if ( ! global [ '__Zone_disable_' + name ] ) {
698700 const perfName = 'Zone:' + name ;
699701 mark ( perfName ) ;
@@ -1364,4 +1366,4 @@ const Zone: ZoneType = (function(global: any) {
13641366
13651367 performanceMeasure ( 'Zone' , 'Zone' ) ;
13661368 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