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

fix: commonjs wrapper #125

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions zone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

(function (window) {


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

if (setName === 'setInterval') {
zone[setName] = function (fn) {
window.zone[setName] = function (fn) {
var id;
arguments[0] = function () {
delete ids[id];
Expand All @@ -130,7 +132,7 @@ Zone.patchSetClearFn = function (obj, fnNames) {
return id;
};
} else {
zone[setName] = function (fn) {
window.zone[setName] = function (fn) {
var id;
arguments[0] = function () {
delete ids[id];
Expand Down Expand Up @@ -538,13 +540,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 = new Zone();
Zone.patch();
};


Zone.init();

window.Zone = Zone;

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