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

Commit fb338b6

Browse files
committed
feat(Zone): add unique id to each zone
Closes #45
1 parent 214f532 commit fb338b6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: test/zone.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ describe('Zone', function () {
66
zone.mark = 'root';
77
});
88

9+
it('should have an id', function () {
10+
expect(zone.$id).toBeDefined();
11+
});
12+
13+
it('forked zones should have a greater id than their parent', function () {
14+
expect(zone.fork().$id).toBeGreaterThan(zone.$id);
15+
});
16+
917
describe('hooks', function () {
1018

1119
it('should fire beforeTask before a zone runs a function', function () {

Diff for: zone.js

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function Zone(parentZone, data) {
4545
}
4646
});
4747

48+
zone.$id = ++Zone.nextId;
49+
4850
return zone;
4951
}
5052

@@ -166,6 +168,8 @@ Zone.patchSetClearFn = function (obj, fnNames) {
166168
});
167169
};
168170

171+
Zone.nextId = 1;
172+
169173

170174
Zone.patchSetFn = function (obj, fnNames) {
171175
fnNames.forEach(function (name) {

0 commit comments

Comments
 (0)