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

feat(Zone): check global for rootZoneSpec #521

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,14 @@ const Zone: ZoneType = (function(global: any) {
const symbolPromise = __symbol__('Promise');
const symbolThen = __symbol__('then');

let _currentZoneFrame = new ZoneFrame(null, new Zone(null, null));
const symbolRootZoneSpec = '__rootZoneSpec__';
let rootZone: Zone = new Zone(null, null);
if (global[symbolRootZoneSpec]) {
rootZone = <Zone>rootZone.fork(global[symbolRootZoneSpec]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delete the rootZoneSpec after create rootZone?

 const symbolRootZoneSpec = '__rootZoneSpec__'
 var rootZone: Zone = new Zone(null, null);
 if (global[symbolRootZoneSpec]) {
   rootZone = <Zone>rootZone.fork(global[symbolRootZoneSpec]);
   delete global[symbolRootZoneSpec];
 }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should so that we don't clutter global space.
I can't see any reason not to.

delete global[symbolRootZoneSpec];
}

let _currentZoneFrame = new ZoneFrame(null, rootZone);
let _currentTask: Task = null;
let _microTaskQueue: Task[] = [];
let _isDrainingMicrotaskQueue: boolean = false;
Expand Down