diff --git a/test/zone.spec.js b/test/zone.spec.js index 790d89d3c..1e1aa8cf4 100644 --- a/test/zone.spec.js +++ b/test/zone.spec.js @@ -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 () { diff --git a/zone.js b/zone.js index a2c327401..2f80837b6 100644 --- a/zone.js +++ b/zone.js @@ -45,6 +45,8 @@ function Zone(parentZone, data) { } }); + zone.$id = ++Zone.nextId; + return zone; } @@ -166,6 +168,8 @@ Zone.patchSetClearFn = function (obj, fnNames) { }); }; +Zone.nextId = 1; + Zone.patchSetFn = function (obj, fnNames) { fnNames.forEach(function (name) {