From fb338b685602a0ad9f0d1c9e2034796630a078b0 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Fri, 20 Feb 2015 12:45:19 -0800 Subject: [PATCH] feat(Zone): add unique id to each zone Closes #45 --- test/zone.spec.js | 8 ++++++++ zone.js | 4 ++++ 2 files changed, 12 insertions(+) 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) {