Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 8ce5e33

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(duplicate): fix#1081, load patch should also check the duplicate flag (#1121)
1 parent 96420d6 commit 8ce5e33

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎lib/zone.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ const Zone: ZoneType = (function(global: any) {
643643
performance&&performance['measure']&&performance['measure'](name,label);
644644
}
645645
mark('Zone');
646+
constcheckDuplicate=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-
typeofglobal['Zone'].__symbol__!=='function'){
657+
if(checkDuplicate||typeofglobal['Zone'].__symbol__!=='function'){
658658
thrownewError('Zone already loaded.');
659659
}else{
660660
returnglobal['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-
throwError('Already loaded patch: '+name);
696+
if(checkDuplicate){
697+
throwError('Already loaded patch: '+name);
698+
}
697699
}elseif(!global['__Zone_disable_'+name]){
698700
constperfName='Zone:'+name;
699701
mark(perfName);
@@ -1364,4 +1366,4 @@ const Zone: ZoneType = (function(global: any) {
13641366

13651367
performanceMeasure('Zone','Zone');
13661368
returnglobal['Zone']=Zone;
1367-
})(typeofwindow!=='undefined'&&window||typeofself!=='undefined'&&self||global);
1369+
})(typeofwindow!=='undefined'&&window||typeofself!=='undefined'&&self||global);

0 commit comments

Comments
 (0)