Skip to content

Commit ffb2ab1

Browse files
committed
chore: release v0.8.4
1 parent bcd09a0 commit ffb2ab1

8 files changed

+77
-442
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name="0.8.4"></a>
2+
## [0.8.4](https://github.com/angular/zone.js/compare/v0.8.3...0.8.4) (2017-03-16)
3+
4+
5+
### Bug Fixes
6+
7+
* correct declaration which breaks closure ([0e19304](https://github.com/angular/zone.js/commit/0e19304))
8+
* stack rewriting now works with source maps ([bcd09a0](https://github.com/angular/zone.js/commit/bcd09a0))
9+
10+
11+
112
<a name="0.8.3"></a>
213
## [0.8.3](https://github.com/angular/zone.js/compare/v0.8.1...0.8.3) (2017-03-15)
314

dist/long-stack-trace-zone.js

+21-37
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
* @suppress {globalThis}
2424
*/
2525
var NEWLINE = '\n';
26-
var SEP = ' ------------- ';
27-
var IGNORE_FRAMES = [];
26+
var IGNORE_FRAMES = {};
2827
var creationTrace = '__creationTrace__';
28+
var ERROR_TAG = 'STACKTRACE TRACKING';
29+
var SEP_TAG = '__SEP_TAG__';
30+
var sepTemplate = '';
2931
var LongStackTrace = (function () {
3032
function LongStackTrace() {
3133
this.error = getStacktrace();
@@ -34,7 +36,7 @@ var LongStackTrace = (function () {
3436
return LongStackTrace;
3537
}());
3638
function getStacktraceWithUncaughtError() {
37-
return new Error('STACKTRACE TRACKING');
39+
return new Error(ERROR_TAG);
3840
}
3941
function getStacktraceWithCaughtError() {
4042
try {
@@ -59,19 +61,21 @@ function addErrorStack(lines, error) {
5961
for (var i = 0; i < trace.length; i++) {
6062
var frame = trace[i];
6163
// Filter out the Frames which are part of stack capturing.
62-
if (!(i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) {
64+
if (!IGNORE_FRAMES.hasOwnProperty(frame)) {
6365
lines.push(trace[i]);
6466
}
6567
}
6668
}
6769
function renderLongStackTrace(frames, stack) {
68-
var longTrace = [stack];
70+
var longTrace = [stack.trim()];
6971
if (frames) {
7072
var timestamp = new Date().getTime();
7173
for (var i = 0; i < frames.length; i++) {
7274
var traceFrames = frames[i];
7375
var lastTime = traceFrames.timestamp;
74-
longTrace.push(SEP + " Elapsed: " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime + " " + SEP);
76+
var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime;
77+
separator = separator.replace(/[^\w\d]/g, '_');
78+
longTrace.push(sepTemplate.replace(SEP_TAG, separator));
7579
addErrorStack(longTrace, traceFrames.error);
7680
timestamp = lastTime.getTime();
7781
}
@@ -109,40 +113,12 @@ Zone['longStackTraceZoneSpec'] = {
109113
onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) {
110114
var parentTask = Zone.currentTask || error.task;
111115
if (error instanceof Error && parentTask) {
112-
var stackSetSucceeded = null;
116+
var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
113117
try {
114-
var descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
115-
if (descriptor && descriptor.configurable) {
116-
var delegateGet_1 = descriptor.get;
117-
var value_1 = descriptor.value;
118-
descriptor = {
119-
get: function () {
120-
return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet_1 ? delegateGet_1.apply(this) : value_1);
121-
}
122-
};
123-
Object.defineProperty(error, 'stack', descriptor);
124-
stackSetSucceeded = true;
125-
}
118+
error.stack = error.longStack = longStack;
126119
}
127120
catch (err) {
128121
}
129-
var longStack = stackSetSucceeded ?
130-
null :
131-
renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
132-
if (!stackSetSucceeded) {
133-
try {
134-
stackSetSucceeded = error.stack = longStack;
135-
}
136-
catch (err) {
137-
}
138-
}
139-
if (!stackSetSucceeded) {
140-
try {
141-
stackSetSucceeded = error.longStack = longStack;
142-
}
143-
catch (err) {
144-
}
145-
}
146122
}
147123
return parentZoneDelegate.handleError(targetZone, error);
148124
}
@@ -161,12 +137,20 @@ function computeIgnoreFrames() {
161137
for (var i = 0; i < frames1.length; i++) {
162138
var frame1 = frames1[i];
163139
var frame2 = frames2[i];
140+
if (!sepTemplate && frame1.indexOf(ERROR_TAG) == -1) {
141+
sepTemplate = frame1.replace(/^(\s*(at)?\s*)([\w\/\<]+)/, '$1' + SEP_TAG);
142+
}
164143
if (frame1 === frame2) {
165-
IGNORE_FRAMES.push(frame1);
144+
IGNORE_FRAMES[frame1] = true;
166145
}
167146
else {
168147
break;
169148
}
149+
console.log('>>>>>>', sepTemplate, frame1);
150+
}
151+
if (!sepTemplate) {
152+
// If we could not find it default to this text.
153+
sepTemplate = SEP_TAG + '@[native code]';
170154
}
171155
}
172156
computeIgnoreFrames();

dist/long-stack-trace-zone.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zone-mix.js

+14-134
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
280280
};
281281
var ZoneDelegate = (function () {
282282
function ZoneDelegate(zone, parentDelegate, zoneSpec) {
283-
this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 };
283+
this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 };
284284
this.zone = zone;
285285
this._parentDelegate = parentDelegate;
286286
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
919919
var zoneAwareErrorStartFrames = [];
920920
global.Error = ZoneAwareError;
921921
var stackRewrite = 'stackRewrite';
922-
// fix #595, create property descriptor
923-
// for error properties
924-
var createProperty = function (props, key) {
925-
// if property is already defined, skip it.
926-
if (props[key]) {
927-
return;
928-
}
929-
// define a local property
930-
// in case error property is not settable
931-
var name = __symbol__(key);
932-
props[key] = {
933-
configurable: true,
934-
enumerable: true,
935-
get: function () {
936-
// if local property has no value
937-
// use internal error's property value
938-
if (!this[name]) {
939-
var error_2 = this[__symbol__('error')];
940-
if (error_2) {
941-
this[name] = error_2[key];
942-
}
943-
}
944-
return this[name];
945-
},
946-
set: function (value) {
947-
// setter will set value to local property value
948-
this[name] = value;
949-
}
950-
};
951-
};
952-
// fix #595, create property descriptor
953-
// for error method properties
954-
var createMethodProperty = function (props, key) {
955-
if (props[key]) {
956-
return;
957-
}
958-
props[key] = {
959-
configurable: true,
960-
enumerable: true,
961-
writable: true,
962-
value: function () {
963-
var error = this[__symbol__('error')];
964-
var errorMethod = (error && error[key]) || this[key];
965-
if (errorMethod) {
966-
return errorMethod.apply(error, arguments);
967-
}
968-
}
969-
};
970-
};
971-
var createErrorProperties = function () {
972-
var props = Object.create(null);
973-
var error = new NativeError();
974-
var keys = Object.getOwnPropertyNames(error);
975-
for (var i = 0; i < keys.length; i++) {
976-
var key = keys[i];
977-
// Avoid bugs when hasOwnProperty is shadowed
978-
if (Object.prototype.hasOwnProperty.call(error, key)) {
979-
createProperty(props, key);
980-
}
981-
}
982-
var proto = NativeError.prototype;
983-
if (proto) {
984-
var pKeys = Object.getOwnPropertyNames(proto);
985-
for (var i = 0; i < pKeys.length; i++) {
986-
var key = pKeys[i];
987-
// skip constructor
988-
if (key !== 'constructor' && key !== 'toString' && key !== 'toSource') {
989-
createProperty(props, key);
990-
}
991-
}
992-
}
993-
// some other properties are not
994-
// in NativeError
995-
createProperty(props, 'originalStack');
996-
createProperty(props, 'zoneAwareStack');
997-
// in IE, stack is not in prototype
998-
createProperty(props, 'stack');
999-
// define toString, toSource as method property
1000-
createMethodProperty(props, 'toString');
1001-
createMethodProperty(props, 'toSource');
1002-
return props;
1003-
};
1004-
var errorProperties = createErrorProperties();
1005-
// for derived Error class which extends ZoneAwareError
1006-
// we should not override the derived class's property
1007-
// so we create a new props object only copy the properties
1008-
// from errorProperties which not exist in derived Error's prototype
1009-
var getErrorPropertiesForPrototype = function (prototype) {
1010-
// if the prototype is ZoneAwareError.prototype
1011-
// we just return the prebuilt errorProperties.
1012-
if (prototype === ZoneAwareError.prototype) {
1013-
return errorProperties;
1014-
}
1015-
var newProps = Object.create(null);
1016-
var cKeys = Object.getOwnPropertyNames(errorProperties);
1017-
var keys = Object.getOwnPropertyNames(prototype);
1018-
cKeys.forEach(function (cKey) {
1019-
if (keys.filter(function (key) {
1020-
return key === cKey;
1021-
})
1022-
.length === 0) {
1023-
newProps[cKey] = errorProperties[cKey];
1024-
}
1025-
});
1026-
return newProps;
1027-
};
1028922
// some functions are not easily to be detected here,
1029923
// for example Timeout.ZoneTask.invoke, if we want to detect those functions
1030924
// by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
1033927
'ZoneTask.invoke', 'ZoneAware', 'getStacktraceWithUncaughtError', 'new LongStackTrace',
1034928
'long-stack-trace'
1035929
];
1036-
function attachZoneAndRemoveInternalZoneFrames(error, zoneAwareError) {
930+
function attachZoneAndRemoveInternalZoneFrames(error) {
1037931
// Save original stack trace
1038932
error.originalStack = error.stack;
1039933
// Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
1087981
catch (nonWritableErr) {
1088982
// in some browser, the error.stack is readonly such as PhantomJS
1089983
// so we need to store the stack frames to zoneAwareError directly
1090-
zoneAwareError.stack = finalStack;
1091984
}
1092985
}
1093986
}
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
1096989
* adds zone information to it.
1097990
*/
1098991
function ZoneAwareError() {
1099-
// make sure we have a valid this
1100-
// if this is undefined(call Error without new) or this is global
1101-
// or this is some other objects, we should force to create a
1102-
// valid ZoneAwareError by call Object.create()
1103-
if (!(this instanceof ZoneAwareError)) {
1104-
return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments);
1105-
}
1106-
// Create an Error.
992+
// We always have to return native error otherwise the browser console will not work.
1107993
var error = NativeError.apply(this, arguments);
1108994
if (!error.stack) {
1109995
// in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
11161002
error = err;
11171003
}
11181004
}
1119-
this[__symbol__('error')] = error;
11201005
// 1. attach zone information to stack frame
11211006
// 2. remove zone internal stack frames
1122-
attachZoneAndRemoveInternalZoneFrames(error, this);
1123-
// use defineProperties here instead of copy property value
1124-
// because of issue #595 which will break angular2.
1125-
var props = getErrorPropertiesForPrototype(Object.getPrototypeOf(this));
1126-
Object.defineProperties(this, props);
1127-
return this;
1007+
attachZoneAndRemoveInternalZoneFrames(error);
1008+
return error;
11281009
}
11291010
// Copy the prototype so that instanceof operator works as expected
11301011
ZoneAwareError.prototype = NativeError.prototype;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
12581139
// 1. IE issue, the error.stack can only be not undefined after throw
12591140
// 2. handle Error(...) without new options
12601141
var throwError = function (message, withNew) {
1261-
if (withNew === void 0) { withNew = true; }
1262-
var error;
12631142
try {
12641143
if (withNew) {
12651144
throw new Error(message);
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
12691148
}
12701149
}
12711150
catch (err) {
1272-
error = err;
1151+
return err;
12731152
}
1274-
return error;
12751153
};
12761154
var nativeStackTraceLimit = NativeError.stackTraceLimit;
12771155
// in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
12841162
var detectRunFn = function () {
12851163
detectZone.run(function () {
12861164
detectZone.runGuarded(function () {
1287-
throw throwError('blacklistStackFrames');
1165+
throw throwError('blacklistStackFrames', true);
12881166
});
12891167
});
12901168
};
12911169
var detectRunWithoutNewFn = function () {
12921170
detectZone.run(function () {
12931171
detectZone.runGuarded(function () {
1294-
throw throwError('blacklistStackFrames', false);
1172+
throw throwError('blacklistStackFrames');
12951173
});
12961174
});
12971175
};
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
14401318
detectZoneWithCallbacks.runGuarded(detectPromiseCaughtWithoutNewFn);
14411319
NativeError.stackTraceLimit = nativeStackTraceLimit;
14421320
return global['Zone'] = Zone;
1443-
})(typeof window === 'object' && window || typeof self === 'object' && self || global);
1321+
})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
14441322

14451323
/**
14461324
* @license
@@ -1945,14 +1823,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
19451823
var tasksByHandleId = {};
19461824
function scheduleTask(task) {
19471825
var data = task.data;
1948-
data.args[0] = function () {
1826+
function timer() {
19491827
try {
19501828
task.invoke.apply(this, arguments);
19511829
}
19521830
finally {
19531831
delete tasksByHandleId[data.handleId];
19541832
}
1955-
};
1833+
}
1834+
1835+
data.args[0] = timer;
19561836
data.handleId = setNative.apply(window, data.args);
19571837
tasksByHandleId[data.handleId] = task;
19581838
return task;
@@ -2330,7 +2210,7 @@ function registerElementPatch(_global) {
23302210
var set = 'set';
23312211
var clear = 'clear';
23322212
var blockingMethods = ['alert', 'prompt', 'confirm'];
2333-
var _global = typeof window === 'object' && window || typeof self === 'object' && self || global;
2213+
var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global;
23342214
patchTimer(_global, set, clear, 'Timeout');
23352215
patchTimer(_global, set, clear, 'Interval');
23362216
patchTimer(_global, set, clear, 'Immediate');

0 commit comments

Comments
 (0)