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

Commit 1ba8519

Browse files
committed
chare: release v0.8.26
1 parent b3fdd7e commit 1ba8519

10 files changed

+370
-144
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="0.8.26"></a>
2+
## [0.8.26](https://github.com/angular/zone.js/compare/v0.8.25...0.8.26) (2018-04-08)
3+
4+
5+
### Bug Fixes
6+
7+
* **test:** fix [#1069](https://github.com/angular/zone.js/issues/1069), FakeDate should handle constructor parameter ([#1070](https://github.com/angular/zone.js/issues/1070)) ([b3fdd7e](https://github.com/angular/zone.js/commit/b3fdd7e))
8+
9+
10+
111
<a name="0.8.25"></a>
212
## [0.8.25](https://github.com/angular/zone.js/compare/v0.8.24...0.8.25) (2018-04-04)
313

dist/fake-async-test.js

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,58 @@
1818
* Use of this source code is governed by an MIT-style license that can be
1919
* found in the LICENSE file at https://angular.io/license
2020
*/
21+
var __read = (undefined && undefined.__read) || function (o, n) {
22+
var m = typeof Symbol === "function" && o[Symbol.iterator];
23+
if (!m) return o;
24+
var i = m.call(o), r, ar = [], e;
25+
try {
26+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27+
}
28+
catch (error) { e = { error: error }; }
29+
finally {
30+
try {
31+
if (r && !r.done && (m = i["return"])) m.call(i);
32+
}
33+
finally { if (e) throw e.error; }
34+
}
35+
return ar;
36+
};
37+
var __spread = (undefined && undefined.__spread) || function () {
38+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
39+
return ar;
40+
};
2141
(function (global) {
2242
var OriginalDate = global.Date;
2343
var FakeDate = /** @class */ (function () {
2444
function FakeDate() {
25-
var d = new OriginalDate();
26-
d.setTime(global.Date.now());
27-
return d;
45+
if (arguments.length === 0) {
46+
var d = new OriginalDate();
47+
d.setTime(FakeDate.now());
48+
return d;
49+
}
50+
else {
51+
var args = Array.prototype.slice.call(arguments);
52+
return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))();
53+
}
2854
}
29-
FakeDate.UTC = function () {
30-
return OriginalDate.UTC();
31-
};
3255
FakeDate.now = function () {
3356
var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
3457
if (fakeAsyncTestZoneSpec) {
3558
return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime();
3659
}
3760
return OriginalDate.now.apply(this, arguments);
3861
};
39-
FakeDate.parse = function () {
40-
return OriginalDate.parse();
41-
};
4262
return FakeDate;
4363
}());
64+
FakeDate.UTC = OriginalDate.UTC;
65+
FakeDate.parse = OriginalDate.parse;
66+
// keep a reference for zone patched timer function
67+
var timers = {
68+
setTimeout: global.setTimeout,
69+
setInterval: global.setInterval,
70+
clearTimeout: global.clearTimeout,
71+
clearInterval: global.clearInterval
72+
};
4473
var Scheduler = /** @class */ (function () {
4574
function Scheduler() {
4675
// Next scheduler id.
@@ -50,7 +79,7 @@
5079
// Current simulated time in millis.
5180
this._currentTime = 0;
5281
// Current real time in millis.
53-
this._currentRealTime = Date.now();
82+
this._currentRealTime = OriginalDate.now();
5483
}
5584
Scheduler.prototype.getCurrentTime = function () {
5685
return this._currentTime;
@@ -309,12 +338,26 @@
309338
}
310339
global['Date'] = FakeDate;
311340
FakeDate.prototype = OriginalDate.prototype;
341+
// try check and reset timers
342+
// because jasmine.clock().install() may
343+
// have replaced the global timer
344+
FakeAsyncTestZoneSpec.checkTimerPatch();
312345
};
313346
FakeAsyncTestZoneSpec.resetDate = function () {
314347
if (global['Date'] === FakeDate) {
315348
global['Date'] = OriginalDate;
316349
}
317350
};
351+
FakeAsyncTestZoneSpec.checkTimerPatch = function () {
352+
if (global.setTimeout !== timers.setTimeout) {
353+
global.setTimeout = timers.setTimeout;
354+
global.clearTimeout = timers.clearTimeout;
355+
}
356+
if (global.setInterval !== timers.setInterval) {
357+
global.setInterval = timers.setInterval;
358+
global.clearInterval = timers.clearInterval;
359+
}
360+
};
318361
FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () {
319362
this.patchDateLocked = true;
320363
FakeAsyncTestZoneSpec.patchDate();

dist/jasmine-patch.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,48 @@
7676
return originalJasmineFn.apply(this, arguments);
7777
};
7878
});
79-
if (enableClockPatch) {
80-
var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']);
81-
jasmine['clock'] = function () {
82-
var clock = originalClockFn_1.apply(this, arguments);
83-
var originalTick = (clock[symbol('tick')] = clock.tick);
79+
// need to patch jasmine.clock().mockDate and jasmine.clock().tick() so
80+
// they can work properly in FakeAsyncTest
81+
var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']);
82+
jasmine['clock'] = function () {
83+
var clock = originalClockFn.apply(this, arguments);
84+
if (!clock[symbol('patched')]) {
85+
clock[symbol('patched')] = symbol('patched');
86+
var originalTick_1 = (clock[symbol('tick')] = clock.tick);
8487
clock.tick = function () {
8588
var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
8689
if (fakeAsyncZoneSpec) {
8790
return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments);
8891
}
89-
return originalTick.apply(this, arguments);
92+
return originalTick_1.apply(this, arguments);
9093
};
91-
var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate);
94+
var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate);
9295
clock.mockDate = function () {
9396
var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
9497
if (fakeAsyncZoneSpec) {
95-
var dateTime = arguments[0];
98+
var dateTime = arguments.length > 0 ? arguments[0] : new Date();
9699
return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] :
97100
arguments);
98101
}
99-
return originalMockDate.apply(this, arguments);
102+
return originalMockDate_1.apply(this, arguments);
100103
};
101-
['install', 'uninstall'].forEach(function (methodName) {
102-
var originalClockFn = (clock[symbol(methodName)] = clock[methodName]);
103-
clock[methodName] = function () {
104-
var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec'];
105-
if (FakeAsyncTestZoneSpec) {
106-
jasmine[symbol('clockInstalled')] = 'install' === methodName;
107-
return;
108-
}
109-
return originalClockFn.apply(this, arguments);
110-
};
111-
});
112-
return clock;
113-
};
114-
}
104+
// for auto go into fakeAsync feature, we need the flag to enable it
105+
if (enableClockPatch) {
106+
['install', 'uninstall'].forEach(function (methodName) {
107+
var originalClockFn = (clock[symbol(methodName)] = clock[methodName]);
108+
clock[methodName] = function () {
109+
var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec'];
110+
if (FakeAsyncTestZoneSpec) {
111+
jasmine[symbol('clockInstalled')] = 'install' === methodName;
112+
return;
113+
}
114+
return originalClockFn.apply(this, arguments);
115+
};
116+
});
117+
}
118+
}
119+
return clock;
120+
};
115121
/**
116122
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
117123
* synchronous-only zone.

dist/jasmine-patch.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zone-patch-resize-observer.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
(factory());
1212
}(this, (function () { 'use strict';
1313

14+
var __values = (undefined && undefined.__values) || function (o) {
15+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
16+
if (m) return m.call(o);
17+
return {
18+
next: function () {
19+
if (o && i >= o.length) o = void 0;
20+
return { value: o && o[i++], done: !o };
21+
}
22+
};
23+
};
1424
/**
1525
* @license
1626
* Copyright Google Inc. All Rights Reserved.
@@ -31,17 +41,26 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) {
3141
var _this = this;
3242
var zones = {};
3343
var currZone = Zone.current;
34-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
35-
var entry = entries_1[_i];
36-
var zone = entry.target[resizeObserverSymbol];
37-
if (!zone) {
38-
zone = currZone;
44+
try {
45+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
46+
var entry = entries_1_1.value;
47+
var zone = entry.target[resizeObserverSymbol];
48+
if (!zone) {
49+
zone = currZone;
50+
}
51+
var zoneEntriesInfo = zones[zone.name];
52+
if (!zoneEntriesInfo) {
53+
zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone };
54+
}
55+
zoneEntriesInfo.entries.push(entry);
3956
}
40-
var zoneEntriesInfo = zones[zone.name];
41-
if (!zoneEntriesInfo) {
42-
zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone };
57+
}
58+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
59+
finally {
60+
try {
61+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
4362
}
44-
zoneEntriesInfo.entries.push(entry);
63+
finally { if (e_1) throw e_1.error; }
4564
}
4665
Object.keys(zones).forEach(function (zoneName) {
4766
var zoneEntriesInfo = zones[zoneName];
@@ -52,6 +71,7 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) {
5271
callback.call(_this, zoneEntriesInfo.entries, observer);
5372
}
5473
});
74+
var e_1, _a;
5575
};
5676
}
5777
return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver();

0 commit comments

Comments
 (0)