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

Commit

Permalink
feat: add isRootZone api
Browse files Browse the repository at this point in the history
For now I'm not documenting this api.

I think it generally useful and harmless enough that it could be a
public api.
  • Loading branch information
IgorMinar authored and vicb committed May 8, 2015
1 parent 038bdd9 commit bf925bf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
6 changes: 5 additions & 1 deletion dist/zone-microtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ browserPatch.apply();
function Zone(parentZone, data) {
var zone = (arguments.length) ? Object.create(parentZone) : this;

zone.parent = parentZone;
zone.parent = parentZone || null;

Object.keys(data || {}).forEach(function(property) {

Expand Down Expand Up @@ -98,6 +98,10 @@ Zone.prototype = {
});
},

isRootZone: function() {
return this.parent === null;
},

run: function run (fn, applyTo, applyWith) {
applyWith = applyWith || [];

Expand Down
2 changes: 1 addition & 1 deletion dist/zone-microtask.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ browserPatch.apply();
function Zone(parentZone, data) {
var zone = (arguments.length) ? Object.create(parentZone) : this;

zone.parent = parentZone;
zone.parent = parentZone || null;

Object.keys(data || {}).forEach(function(property) {

Expand Down Expand Up @@ -93,6 +93,10 @@ Zone.prototype = {
});
},

isRootZone: function() {
return this.parent === null;
},

run: function run (fn, applyTo, applyWith) {
applyWith = applyWith || [];

Expand Down
2 changes: 1 addition & 1 deletion dist/zone.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function Zone(parentZone, data) {
var zone = (arguments.length) ? Object.create(parentZone) : this;

zone.parent = parentZone;
zone.parent = parentZone || null;

Object.keys(data || {}).forEach(function(property) {

Expand Down Expand Up @@ -74,6 +74,10 @@ Zone.prototype = {
});
},

isRootZone: function() {
return this.parent === null;
},

run: function run (fn, applyTo, applyWith) {
applyWith = applyWith || [];

Expand Down
20 changes: 20 additions & 0 deletions test/zone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ describe('Zone', function () {
});


describe('isRootZone', function() {

it('should return true for root zone', function() {
expect(zone.isRootZone()).toBe(true);
});


it('should return false for non-root zone', function() {
var executed = false;

zone.fork().run(function() {
executed = true;
expect(zone.isRootZone()).toBe(false);
});

expect(executed).toBe(true);
});
});


describe('fork', function () {
it('should fork deep copy', function () {
var protoZone = { too: { deep: true } },
Expand Down

0 comments on commit bf925bf

Please sign in to comment.