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

Commit

Permalink
feat(Zone): add unique id to each zone
Browse files Browse the repository at this point in the history
Closes #45
  • Loading branch information
btford committed Feb 20, 2015
1 parent 214f532 commit fb338b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/zone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ describe('Zone', function () {
zone.mark = 'root';
});

it('should have an id', function () {
expect(zone.$id).toBeDefined();
});

it('forked zones should have a greater id than their parent', function () {
expect(zone.fork().$id).toBeGreaterThan(zone.$id);
});

describe('hooks', function () {

it('should fire beforeTask before a zone runs a function', function () {
Expand Down
4 changes: 4 additions & 0 deletions zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function Zone(parentZone, data) {
}
});

zone.$id = ++Zone.nextId;

return zone;
}

Expand Down Expand Up @@ -166,6 +168,8 @@ Zone.patchSetClearFn = function (obj, fnNames) {
});
};

Zone.nextId = 1;


Zone.patchSetFn = function (obj, fnNames) {
fnNames.forEach(function (name) {
Expand Down

0 comments on commit fb338b6

Please sign in to comment.