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

Commit

Permalink
fix: commonjs wrapper
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
btford committed Apr 10, 2015
1 parent f1cbad9 commit 7b4fdde
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions zone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

(function (window) {

var zone = null;


function Zone(parentZone, data) {
var zone = (arguments.length) ? Object.create(parentZone) : this;
Expand Down Expand Up @@ -79,10 +83,10 @@ Zone.prototype = {
run: function run (fn, applyTo, applyWith) {
applyWith = applyWith || [];

var oldZone = window.zone,
var oldZone = zone,
result;

window.zone = this;
window.zone = zone = this;

try {
this.beforeTask();
Expand All @@ -95,7 +99,7 @@ Zone.prototype = {
}
} finally {
this.afterTask();
window.zone = oldZone;
window.zone = zone = oldZone;
}
return result;
},
Expand Down Expand Up @@ -665,13 +669,14 @@ Zone.onEventNames = Zone.eventNames.map(function (property) {
});

Zone.init = function init () {
if (typeof module !== 'undefined' && module && module.exports) {
module.exports = new Zone();
} else {
window.zone = new Zone();
}
window.zone = zone = new Zone();
Zone.patch();
};


Zone.init();

window.Zone = Zone;

}((typeof module !== 'undefined' && module && module.exports) ?
module.exports : window));

0 comments on commit 7b4fdde

Please sign in to comment.