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

Commit 17ed147

Browse files
committed
fix: commonjs wrapper
Closes #19
1 parent 4b6e411 commit 17ed147

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Diff for: zone.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
(function (window) {
4+
35

46
function Zone(parentZone, data) {
57
var zone = (arguments.length) ? Object.create(parentZone) : this;
@@ -118,7 +120,7 @@ Zone.patchSetClearFn = function (obj, fnNames) {
118120
var ids = {};
119121

120122
if (setName === 'setInterval') {
121-
zone[setName] = function (fn) {
123+
window.zone[setName] = function (fn) {
122124
var id;
123125
arguments[0] = function () {
124126
delete ids[id];
@@ -130,7 +132,7 @@ Zone.patchSetClearFn = function (obj, fnNames) {
130132
return id;
131133
};
132134
} else {
133-
zone[setName] = function (fn) {
135+
window.zone[setName] = function (fn) {
134136
var id;
135137
arguments[0] = function () {
136138
delete ids[id];
@@ -538,13 +540,14 @@ Zone.onEventNames = Zone.eventNames.map(function (property) {
538540
});
539541

540542
Zone.init = function init () {
541-
if (typeof module !== 'undefined' && module && module.exports) {
542-
module.exports = new Zone();
543-
} else {
544-
window.zone = new Zone();
545-
}
543+
window.zone = new Zone();
546544
Zone.patch();
547545
};
548546

549547

550548
Zone.init();
549+
550+
window.Zone = Zone;
551+
552+
}((typeof module !== 'undefined' && module && module.exports) ?
553+
module.exports : window));

0 commit comments

Comments
 (0)