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

Commit b0c5076

Browse files
committed
chore: release v0.8.16
1 parent 6e44cab commit b0c5076

10 files changed

+790
-17
lines changed

CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
<a name="0.8.16"></a>
2+
## [0.8.16](https://github.com/angular/zone.js/compare/v0.8.15...0.8.16) (2017-07-27)
3+
4+
5+
### Bug Fixes
6+
7+
* **console:** console.log in nodejs should run in root Zone ([#855](https://github.com/angular/zone.js/issues/855)) ([5900d3a](https://github.com/angular/zone.js/commit/5900d3a))
8+
* **promise:** fix [#850](https://github.com/angular/zone.js/issues/850), check Promise.then writable ([#851](https://github.com/angular/zone.js/issues/851)) ([6e44cab](https://github.com/angular/zone.js/commit/6e44cab))
9+
* **spec:** do not count requestAnimationFrame as a pending timer ([#854](https://github.com/angular/zone.js/issues/854)) ([eca04b0](https://github.com/angular/zone.js/commit/eca04b0))
10+
11+
12+
### Features
13+
14+
* **spec:** add an option to FakeAsyncTestZoneSpec to flush periodic timers ([#857](https://github.com/angular/zone.js/issues/857)) ([5c5ca1a](https://github.com/angular/zone.js/commit/5c5ca1a))
15+
16+
17+
18+
<a name="0.8.15"></a>
19+
## [0.8.15](https://github.com/angular/zone.js/compare/v0.8.13...0.8.15) (2017-07-27)
20+
21+
22+
### Features
23+
24+
* **rxjs:** fix [#830](https://github.com/angular/zone.js/issues/830), monkey patch rxjs to make rxjs run in correct zone ([#843](https://github.com/angular/zone.js/issues/843)) ([1ed83d0](https://github.com/angular/zone.js/commit/1ed83d0))
25+
26+
27+
128
<a name="0.8.14"></a>
229
## [0.8.14](https://github.com/angular/zone.js/compare/v0.8.13...0.8.14) (2017-07-20)
330

dist/fake-async-test.js

+42-14
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
// Current simulated time in millis.
2929
this._currentTime = 0;
3030
}
31-
Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, id) {
31+
Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) {
3232
if (args === void 0) { args = []; }
3333
if (isPeriodic === void 0) { isPeriodic = false; }
34+
if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; }
3435
if (id === void 0) { id = -1; }
3536
var currentId = id < 0 ? this.nextId++ : id;
3637
var endTime = this._currentTime + delay;
@@ -41,7 +42,8 @@
4142
func: cb,
4243
args: args,
4344
delay: delay,
44-
isPeriodic: isPeriodic
45+
isPeriodic: isPeriodic,
46+
isRequestAnimationFrame: isRequestAnimationFrame
4547
};
4648
var i = 0;
4749
for (; i < this._schedulerQueue.length; i++) {
@@ -83,21 +85,42 @@
8385
}
8486
this._currentTime = finalTime;
8587
};
86-
Scheduler.prototype.flush = function (limit) {
88+
Scheduler.prototype.flush = function (limit, flushPeriodic) {
89+
var _this = this;
8790
if (limit === void 0) { limit = 20; }
91+
if (flushPeriodic === void 0) { flushPeriodic = false; }
8892
var startTime = this._currentTime;
8993
var count = 0;
94+
var seenTimers = [];
9095
while (this._schedulerQueue.length > 0) {
9196
count++;
9297
if (count > limit) {
9398
throw new Error('flush failed after reaching the limit of ' + limit +
9499
' tasks. Does your code use a polling timeout?');
95100
}
96-
// If the only remaining tasks are periodic, finish flushing.
97-
if (!(this._schedulerQueue.filter(function (task) { return !task.isPeriodic; }).length)) {
98-
break;
101+
if (!flushPeriodic) {
102+
// flush only non-periodic timers.
103+
// If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing.
104+
if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; })
105+
.length === 0) {
106+
break;
107+
}
108+
}
109+
else {
110+
// flushPeriodic has been requested.
111+
// Stop when all timer id-s have been seen at least once.
112+
if (this._schedulerQueue
113+
.filter(function (task) {
114+
return seenTimers.indexOf(task.id) === -1 || _this._currentTime === task.endTime;
115+
})
116+
.length === 0) {
117+
break;
118+
}
99119
}
100120
var current = this._schedulerQueue.shift();
121+
if (seenTimers.indexOf(current.id) === -1) {
122+
seenTimers.push(current.id);
123+
}
101124
this._currentTime = current.endTime;
102125
var retval = current.func.apply(global, current.args);
103126
if (!retval) {
@@ -110,7 +133,9 @@
110133
return Scheduler;
111134
}());
112135
var FakeAsyncTestZoneSpec = (function () {
113-
function FakeAsyncTestZoneSpec(namePrefix) {
136+
function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame) {
137+
if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; }
138+
this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame;
114139
this._scheduler = new Scheduler();
115140
this._microtasks = [];
116141
this._lastError = null;
@@ -166,7 +191,7 @@
166191
return function () {
167192
// Requeue the timer callback if it's not been canceled.
168193
if (_this.pendingPeriodicTimers.indexOf(id) !== -1) {
169-
_this._scheduler.scheduleFunction(fn, interval, args, true, id);
194+
_this._scheduler.scheduleFunction(fn, interval, args, true, false, id);
170195
}
171196
};
172197
};
@@ -176,12 +201,15 @@
176201
FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id);
177202
};
178203
};
179-
FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args) {
204+
FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) {
205+
if (isTimer === void 0) { isTimer = true; }
180206
var removeTimerFn = this._dequeueTimer(this._scheduler.nextId);
181207
// Queue the callback and dequeue the timer on success and error.
182208
var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn });
183-
var id = this._scheduler.scheduleFunction(cb, delay, args);
184-
this.pendingTimers.push(id);
209+
var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer);
210+
if (isTimer) {
211+
this.pendingTimers.push(id);
212+
}
185213
return id;
186214
};
187215
FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) {
@@ -237,10 +265,10 @@
237265
}
238266
flushErrors();
239267
};
240-
FakeAsyncTestZoneSpec.prototype.flush = function (limit) {
268+
FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic) {
241269
FakeAsyncTestZoneSpec.assertInZone();
242270
this.flushMicrotasks();
243-
var elapsed = this._scheduler.flush(limit);
271+
var elapsed = this._scheduler.flush(limit, flushPeriodic);
244272
if (this._lastError !== null) {
245273
this._resetLastErrorAndThrow();
246274
}
@@ -283,7 +311,7 @@
283311
case 'mozRequestAnimationFrame':
284312
// Simulate a requestAnimationFrame by using a setTimeout with 16 ms.
285313
// (60 frames per second)
286-
task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args']);
314+
task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame);
287315
break;
288316
default:
289317
throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source);

dist/zone-mix.js

+23
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) {
938938
var originalThen = proto.then;
939939
// Keep a reference to the original method.
940940
proto[symbolThen] = originalThen;
941+
// check Ctor.prototype.then propertyDescritor is writable or not
942+
// in meteor env, writable is false, we have to make it to be true.
943+
var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then');
944+
if (prop && prop.writable === false && prop.configurable) {
945+
Object.defineProperty(Ctor.prototype, 'then', { writable: true });
946+
}
941947
Ctor.prototype.then = function (onResolve, onReject) {
942948
var _this = this;
943949
var wrapped = new ZoneAwarePromise(function (resolve, reject) {
@@ -2929,6 +2935,23 @@ Zone.__load_patch('crypto', function (global, Zone, api) {
29292935
});
29302936
}
29312937
});
2938+
Zone.__load_patch('console', function (global, Zone, api) {
2939+
var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace'];
2940+
consoleMethods.forEach(function (m) {
2941+
var originalMethod = console[Zone.__symbol__(m)] = console[m];
2942+
if (originalMethod) {
2943+
console[m] = function () {
2944+
var args = Array.prototype.slice.call(arguments);
2945+
if (Zone.current === Zone.root) {
2946+
return originalMethod.apply(this, args);
2947+
}
2948+
else {
2949+
return Zone.root.run(originalMethod, this, args);
2950+
}
2951+
};
2952+
}
2953+
});
2954+
});
29322955

29332956
/**
29342957
* @license

dist/zone-node.js

+23
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) {
938938
var originalThen = proto.then;
939939
// Keep a reference to the original method.
940940
proto[symbolThen] = originalThen;
941+
// check Ctor.prototype.then propertyDescritor is writable or not
942+
// in meteor env, writable is false, we have to make it to be true.
943+
var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then');
944+
if (prop && prop.writable === false && prop.configurable) {
945+
Object.defineProperty(Ctor.prototype, 'then', { writable: true });
946+
}
941947
Ctor.prototype.then = function (onResolve, onReject) {
942948
var _this = this;
943949
var wrapped = new ZoneAwarePromise(function (resolve, reject) {
@@ -1914,6 +1920,23 @@ Zone.__load_patch('crypto', function (global, Zone, api) {
19141920
});
19151921
}
19161922
});
1923+
Zone.__load_patch('console', function (global, Zone, api) {
1924+
var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace'];
1925+
consoleMethods.forEach(function (m) {
1926+
var originalMethod = console[Zone.__symbol__(m)] = console[m];
1927+
if (originalMethod) {
1928+
console[m] = function () {
1929+
var args = Array.prototype.slice.call(arguments);
1930+
if (Zone.current === Zone.root) {
1931+
return originalMethod.apply(this, args);
1932+
}
1933+
else {
1934+
return Zone.root.run(originalMethod, this, args);
1935+
}
1936+
};
1937+
}
1938+
});
1939+
});
19171940

19181941
/**
19191942
* @license

0 commit comments

Comments
 (0)