MCPcopy Create free account
hub / github.com/angular/angular / loadZone

Function loadZone

packages/zone.js/lib/zone.ts:70–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70export function loadZone(): ZoneType {
71 // if global['Zone'] already exists (maybe zone.js was already loaded or
72 // some other lib also registered a global object named Zone), we may need
73 // to throw an error, but sometimes user may not want this error.
74 // For example,
75 // we have two web pages, page1 includes zone.js, page2 doesn't.
76 // and the 1st time user load page1 and page2, everything work fine,
77 // but when user load page2 again, error occurs because global['Zone'] already exists.
78 // so we add a flag to let user choose whether to throw this error or not.
79 // By default, if existing Zone is from zone.js, we will not throw the error.
80 const global = globalThis as any;
81 const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true;
82 if (global['Zone'] && (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function')) {
83 throw new Error('Zone already loaded.');
84 }
85
86 // Initialize global `Zone` constant.
87 global['Zone'] ??= initZone();
88 return global['Zone'];
89}

Callers 5

rollup-main.tsFile · 0.90
rollup-mix.tsFile · 0.90
rollupMainFunction · 0.90

Calls 2

__symbol__Function · 0.90
initZoneFunction · 0.90

Tested by

no test coverage detected