diff --git a/CHANGELOG.md b/CHANGELOG.md
index 734594874..b930bf446 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+
+## [0.8.4](https://github.com/angular/zone.js/compare/v0.8.3...0.8.4) (2017-03-16)
+
+
+### Bug Fixes
+
+* correct declaration which breaks closure ([0e19304](https://github.com/angular/zone.js/commit/0e19304))
+* stack rewriting now works with source maps ([bcd09a0](https://github.com/angular/zone.js/commit/bcd09a0))
+
+
+
## [0.8.3](https://github.com/angular/zone.js/compare/v0.8.1...0.8.3) (2017-03-15)
diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js
index a55f06acc..593c36bd1 100644
--- a/dist/long-stack-trace-zone.js
+++ b/dist/long-stack-trace-zone.js
@@ -23,9 +23,11 @@
* @suppress {globalThis}
*/
var NEWLINE = '\n';
-var SEP = ' ------------- ';
-var IGNORE_FRAMES = [];
+var IGNORE_FRAMES = {};
var creationTrace = '__creationTrace__';
+var ERROR_TAG = 'STACKTRACE TRACKING';
+var SEP_TAG = '__SEP_TAG__';
+var sepTemplate = '';
var LongStackTrace = (function () {
function LongStackTrace() {
this.error = getStacktrace();
@@ -34,7 +36,7 @@ var LongStackTrace = (function () {
return LongStackTrace;
}());
function getStacktraceWithUncaughtError() {
- return new Error('STACKTRACE TRACKING');
+ return new Error(ERROR_TAG);
}
function getStacktraceWithCaughtError() {
try {
@@ -59,19 +61,21 @@ function addErrorStack(lines, error) {
for (var i = 0; i < trace.length; i++) {
var frame = trace[i];
// Filter out the Frames which are part of stack capturing.
- if (!(i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) {
+ if (!IGNORE_FRAMES.hasOwnProperty(frame)) {
lines.push(trace[i]);
}
}
}
function renderLongStackTrace(frames, stack) {
- var longTrace = [stack];
+ var longTrace = [stack.trim()];
if (frames) {
var timestamp = new Date().getTime();
for (var i = 0; i < frames.length; i++) {
var traceFrames = frames[i];
var lastTime = traceFrames.timestamp;
- longTrace.push(SEP + " Elapsed: " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime + " " + SEP);
+ var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime;
+ separator = separator.replace(/[^\w\d]/g, '_');
+ longTrace.push(sepTemplate.replace(SEP_TAG, separator));
addErrorStack(longTrace, traceFrames.error);
timestamp = lastTime.getTime();
}
@@ -109,40 +113,12 @@ Zone['longStackTraceZoneSpec'] = {
onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) {
var parentTask = Zone.currentTask || error.task;
if (error instanceof Error && parentTask) {
- var stackSetSucceeded = null;
+ var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
try {
- var descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
- if (descriptor && descriptor.configurable) {
- var delegateGet_1 = descriptor.get;
- var value_1 = descriptor.value;
- descriptor = {
- get: function () {
- return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet_1 ? delegateGet_1.apply(this) : value_1);
- }
- };
- Object.defineProperty(error, 'stack', descriptor);
- stackSetSucceeded = true;
- }
+ error.stack = error.longStack = longStack;
}
catch (err) {
}
- var longStack = stackSetSucceeded ?
- null :
- renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
- if (!stackSetSucceeded) {
- try {
- stackSetSucceeded = error.stack = longStack;
- }
- catch (err) {
- }
- }
- if (!stackSetSucceeded) {
- try {
- stackSetSucceeded = error.longStack = longStack;
- }
- catch (err) {
- }
- }
}
return parentZoneDelegate.handleError(targetZone, error);
}
@@ -161,12 +137,20 @@ function computeIgnoreFrames() {
for (var i = 0; i < frames1.length; i++) {
var frame1 = frames1[i];
var frame2 = frames2[i];
+ if (!sepTemplate && frame1.indexOf(ERROR_TAG) == -1) {
+ sepTemplate = frame1.replace(/^(\s*(at)?\s*)([\w\/\<]+)/, '$1' + SEP_TAG);
+ }
if (frame1 === frame2) {
- IGNORE_FRAMES.push(frame1);
+ IGNORE_FRAMES[frame1] = true;
}
else {
break;
}
+ console.log('>>>>>>', sepTemplate, frame1);
+ }
+ if (!sepTemplate) {
+ // If we could not find it default to this text.
+ sepTemplate = SEP_TAG + '@[native code]';
}
}
computeIgnoreFrames();
diff --git a/dist/long-stack-trace-zone.min.js b/dist/long-stack-trace-zone.min.js
index 59cf38dbe..d18dbc57a 100644
--- a/dist/long-stack-trace-zone.min.js
+++ b/dist/long-stack-trace-zone.min.js
@@ -1 +1 @@
-!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?a():"function"==typeof define&&define.amd?define(a):a()}(this,function(){"use strict";function t(){return new Error("STACKTRACE TRACKING")}function a(){try{throw t()}catch(a){return a}}function e(t){return t.stack?t.stack.split(i):[]}function n(t,a){for(var n=e(a),r=0;r0&&(t.push(e((new l).error)),c(t,a-1))}function o(){var t=[];c(t,2);for(var a=t[0],e=t[1],n=0;nthis.longStackTraceLimit&&(c.length=this.longStackTraceLimit),n.data||(n.data={}),n.data[f]=c,t.scheduleTask(e,n)},onHandleError:function(t,a,e,n){var c=Zone.currentTask||n.task;if(n instanceof Error&&c){var o=null;try{var i=Object.getOwnPropertyDescriptor(n,"stack");if(i&&i.configurable){var u=i.get,s=i.value;i={get:function(){return r(c.data&&c.data[f],u?u.apply(this):s)}},Object.defineProperty(n,"stack",i),o=!0}}catch(l){}var d=o?null:r(c.data&&c.data[f],n.stack);if(!o)try{o=n.stack=d}catch(l){}if(!o)try{o=n.longStack=d}catch(l){}}return t.handleError(e,n)}},o()});
\ No newline at end of file
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";function t(){return new Error(_)}function e(){try{throw t()}catch(e){return e}}function n(t){return t.stack?t.stack.split(i):[]}function a(t,e){for(var a=n(e),r=0;r0&&(t.push(n((new l).error)),c(t,e-1))}function o(){var t=[];c(t,2);for(var e=t[0],n=t[1],a=0;a>>>>>",d,r)}d||(d=f+"@[native code]")}var i="\n",s={},u="__creationTrace__",_="STACKTRACE TRACKING",f="__SEP_TAG__",d="",l=function(){function t(){this.error=g(),this.timestamp=new Date}return t}(),k=t(),h=e(),g=k.stack?t:h.stack?e:t;Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,getLongStackTrace:function(t){if(t){var e=t[Zone.__symbol__("currentTask")],n=e&&e.data&&e.data[u];return n?r(n,t.stack):t.stack}},onScheduleTask:function(t,e,n,a){var r=Zone.currentTask,c=r&&r.data&&r.data[u]||[];return c=[new l].concat(c),c.length>this.longStackTraceLimit&&(c.length=this.longStackTraceLimit),a.data||(a.data={}),a.data[u]=c,t.scheduleTask(n,a)},onHandleError:function(t,e,n,a){var c=Zone.currentTask||a.task;if(a instanceof Error&&c){var o=r(c.data&&c.data[u],a.stack);try{a.stack=a.longStack=o}catch(i){}}return t.handleError(n,a)}},o()});
\ No newline at end of file
diff --git a/dist/zone-mix.js b/dist/zone-mix.js
index a5021dfaf..ffe0c2917 100644
--- a/dist/zone-mix.js
+++ b/dist/zone-mix.js
@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
};
var ZoneDelegate = (function () {
function ZoneDelegate(zone, parentDelegate, zoneSpec) {
- this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 };
+ this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 };
this.zone = zone;
this._parentDelegate = parentDelegate;
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
var zoneAwareErrorStartFrames = [];
global.Error = ZoneAwareError;
var stackRewrite = 'stackRewrite';
- // fix #595, create property descriptor
- // for error properties
- var createProperty = function (props, key) {
- // if property is already defined, skip it.
- if (props[key]) {
- return;
- }
- // define a local property
- // in case error property is not settable
- var name = __symbol__(key);
- props[key] = {
- configurable: true,
- enumerable: true,
- get: function () {
- // if local property has no value
- // use internal error's property value
- if (!this[name]) {
- var error_2 = this[__symbol__('error')];
- if (error_2) {
- this[name] = error_2[key];
- }
- }
- return this[name];
- },
- set: function (value) {
- // setter will set value to local property value
- this[name] = value;
- }
- };
- };
- // fix #595, create property descriptor
- // for error method properties
- var createMethodProperty = function (props, key) {
- if (props[key]) {
- return;
- }
- props[key] = {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function () {
- var error = this[__symbol__('error')];
- var errorMethod = (error && error[key]) || this[key];
- if (errorMethod) {
- return errorMethod.apply(error, arguments);
- }
- }
- };
- };
- var createErrorProperties = function () {
- var props = Object.create(null);
- var error = new NativeError();
- var keys = Object.getOwnPropertyNames(error);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- // Avoid bugs when hasOwnProperty is shadowed
- if (Object.prototype.hasOwnProperty.call(error, key)) {
- createProperty(props, key);
- }
- }
- var proto = NativeError.prototype;
- if (proto) {
- var pKeys = Object.getOwnPropertyNames(proto);
- for (var i = 0; i < pKeys.length; i++) {
- var key = pKeys[i];
- // skip constructor
- if (key !== 'constructor' && key !== 'toString' && key !== 'toSource') {
- createProperty(props, key);
- }
- }
- }
- // some other properties are not
- // in NativeError
- createProperty(props, 'originalStack');
- createProperty(props, 'zoneAwareStack');
- // in IE, stack is not in prototype
- createProperty(props, 'stack');
- // define toString, toSource as method property
- createMethodProperty(props, 'toString');
- createMethodProperty(props, 'toSource');
- return props;
- };
- var errorProperties = createErrorProperties();
- // for derived Error class which extends ZoneAwareError
- // we should not override the derived class's property
- // so we create a new props object only copy the properties
- // from errorProperties which not exist in derived Error's prototype
- var getErrorPropertiesForPrototype = function (prototype) {
- // if the prototype is ZoneAwareError.prototype
- // we just return the prebuilt errorProperties.
- if (prototype === ZoneAwareError.prototype) {
- return errorProperties;
- }
- var newProps = Object.create(null);
- var cKeys = Object.getOwnPropertyNames(errorProperties);
- var keys = Object.getOwnPropertyNames(prototype);
- cKeys.forEach(function (cKey) {
- if (keys.filter(function (key) {
- return key === cKey;
- })
- .length === 0) {
- newProps[cKey] = errorProperties[cKey];
- }
- });
- return newProps;
- };
// some functions are not easily to be detected here,
// for example Timeout.ZoneTask.invoke, if we want to detect those functions
// by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
'ZoneTask.invoke', 'ZoneAware', 'getStacktraceWithUncaughtError', 'new LongStackTrace',
'long-stack-trace'
];
- function attachZoneAndRemoveInternalZoneFrames(error, zoneAwareError) {
+ function attachZoneAndRemoveInternalZoneFrames(error) {
// Save original stack trace
error.originalStack = error.stack;
// Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
catch (nonWritableErr) {
// in some browser, the error.stack is readonly such as PhantomJS
// so we need to store the stack frames to zoneAwareError directly
- zoneAwareError.stack = finalStack;
}
}
}
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
* adds zone information to it.
*/
function ZoneAwareError() {
- // make sure we have a valid this
- // if this is undefined(call Error without new) or this is global
- // or this is some other objects, we should force to create a
- // valid ZoneAwareError by call Object.create()
- if (!(this instanceof ZoneAwareError)) {
- return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments);
- }
- // Create an Error.
+ // We always have to return native error otherwise the browser console will not work.
var error = NativeError.apply(this, arguments);
if (!error.stack) {
// in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
error = err;
}
}
- this[__symbol__('error')] = error;
// 1. attach zone information to stack frame
// 2. remove zone internal stack frames
- attachZoneAndRemoveInternalZoneFrames(error, this);
- // use defineProperties here instead of copy property value
- // because of issue #595 which will break angular2.
- var props = getErrorPropertiesForPrototype(Object.getPrototypeOf(this));
- Object.defineProperties(this, props);
- return this;
+ attachZoneAndRemoveInternalZoneFrames(error);
+ return error;
}
// Copy the prototype so that instanceof operator works as expected
ZoneAwareError.prototype = NativeError.prototype;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
// 1. IE issue, the error.stack can only be not undefined after throw
// 2. handle Error(...) without new options
var throwError = function (message, withNew) {
- if (withNew === void 0) { withNew = true; }
- var error;
try {
if (withNew) {
throw new Error(message);
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
}
}
catch (err) {
- error = err;
+ return err;
}
- return error;
};
var nativeStackTraceLimit = NativeError.stackTraceLimit;
// in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
var detectRunFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames');
+ throw throwError('blacklistStackFrames', true);
});
});
};
var detectRunWithoutNewFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames', false);
+ throw throwError('blacklistStackFrames');
});
});
};
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
detectZoneWithCallbacks.runGuarded(detectPromiseCaughtWithoutNewFn);
NativeError.stackTraceLimit = nativeStackTraceLimit;
return global['Zone'] = Zone;
-})(typeof window === 'object' && window || typeof self === 'object' && self || global);
+})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
/**
* @license
@@ -1945,14 +1823,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
var tasksByHandleId = {};
function scheduleTask(task) {
var data = task.data;
- data.args[0] = function () {
+ function timer() {
try {
task.invoke.apply(this, arguments);
}
finally {
delete tasksByHandleId[data.handleId];
}
- };
+ }
+
+ data.args[0] = timer;
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;
@@ -2330,7 +2210,7 @@ function registerElementPatch(_global) {
var set = 'set';
var clear = 'clear';
var blockingMethods = ['alert', 'prompt', 'confirm'];
-var _global = typeof window === 'object' && window || typeof self === 'object' && self || global;
+var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global;
patchTimer(_global, set, clear, 'Timeout');
patchTimer(_global, set, clear, 'Interval');
patchTimer(_global, set, clear, 'Immediate');
diff --git a/dist/zone-node.js b/dist/zone-node.js
index 1d3ec9aa9..4aac4b0d5 100644
--- a/dist/zone-node.js
+++ b/dist/zone-node.js
@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
};
var ZoneDelegate = (function () {
function ZoneDelegate(zone, parentDelegate, zoneSpec) {
- this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 };
+ this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 };
this.zone = zone;
this._parentDelegate = parentDelegate;
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
var zoneAwareErrorStartFrames = [];
global.Error = ZoneAwareError;
var stackRewrite = 'stackRewrite';
- // fix #595, create property descriptor
- // for error properties
- var createProperty = function (props, key) {
- // if property is already defined, skip it.
- if (props[key]) {
- return;
- }
- // define a local property
- // in case error property is not settable
- var name = __symbol__(key);
- props[key] = {
- configurable: true,
- enumerable: true,
- get: function () {
- // if local property has no value
- // use internal error's property value
- if (!this[name]) {
- var error_2 = this[__symbol__('error')];
- if (error_2) {
- this[name] = error_2[key];
- }
- }
- return this[name];
- },
- set: function (value) {
- // setter will set value to local property value
- this[name] = value;
- }
- };
- };
- // fix #595, create property descriptor
- // for error method properties
- var createMethodProperty = function (props, key) {
- if (props[key]) {
- return;
- }
- props[key] = {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function () {
- var error = this[__symbol__('error')];
- var errorMethod = (error && error[key]) || this[key];
- if (errorMethod) {
- return errorMethod.apply(error, arguments);
- }
- }
- };
- };
- var createErrorProperties = function () {
- var props = Object.create(null);
- var error = new NativeError();
- var keys = Object.getOwnPropertyNames(error);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- // Avoid bugs when hasOwnProperty is shadowed
- if (Object.prototype.hasOwnProperty.call(error, key)) {
- createProperty(props, key);
- }
- }
- var proto = NativeError.prototype;
- if (proto) {
- var pKeys = Object.getOwnPropertyNames(proto);
- for (var i = 0; i < pKeys.length; i++) {
- var key = pKeys[i];
- // skip constructor
- if (key !== 'constructor' && key !== 'toString' && key !== 'toSource') {
- createProperty(props, key);
- }
- }
- }
- // some other properties are not
- // in NativeError
- createProperty(props, 'originalStack');
- createProperty(props, 'zoneAwareStack');
- // in IE, stack is not in prototype
- createProperty(props, 'stack');
- // define toString, toSource as method property
- createMethodProperty(props, 'toString');
- createMethodProperty(props, 'toSource');
- return props;
- };
- var errorProperties = createErrorProperties();
- // for derived Error class which extends ZoneAwareError
- // we should not override the derived class's property
- // so we create a new props object only copy the properties
- // from errorProperties which not exist in derived Error's prototype
- var getErrorPropertiesForPrototype = function (prototype) {
- // if the prototype is ZoneAwareError.prototype
- // we just return the prebuilt errorProperties.
- if (prototype === ZoneAwareError.prototype) {
- return errorProperties;
- }
- var newProps = Object.create(null);
- var cKeys = Object.getOwnPropertyNames(errorProperties);
- var keys = Object.getOwnPropertyNames(prototype);
- cKeys.forEach(function (cKey) {
- if (keys.filter(function (key) {
- return key === cKey;
- })
- .length === 0) {
- newProps[cKey] = errorProperties[cKey];
- }
- });
- return newProps;
- };
// some functions are not easily to be detected here,
// for example Timeout.ZoneTask.invoke, if we want to detect those functions
// by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
'ZoneTask.invoke', 'ZoneAware', 'getStacktraceWithUncaughtError', 'new LongStackTrace',
'long-stack-trace'
];
- function attachZoneAndRemoveInternalZoneFrames(error, zoneAwareError) {
+ function attachZoneAndRemoveInternalZoneFrames(error) {
// Save original stack trace
error.originalStack = error.stack;
// Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
catch (nonWritableErr) {
// in some browser, the error.stack is readonly such as PhantomJS
// so we need to store the stack frames to zoneAwareError directly
- zoneAwareError.stack = finalStack;
}
}
}
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
* adds zone information to it.
*/
function ZoneAwareError() {
- // make sure we have a valid this
- // if this is undefined(call Error without new) or this is global
- // or this is some other objects, we should force to create a
- // valid ZoneAwareError by call Object.create()
- if (!(this instanceof ZoneAwareError)) {
- return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments);
- }
- // Create an Error.
+ // We always have to return native error otherwise the browser console will not work.
var error = NativeError.apply(this, arguments);
if (!error.stack) {
// in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
error = err;
}
}
- this[__symbol__('error')] = error;
// 1. attach zone information to stack frame
// 2. remove zone internal stack frames
- attachZoneAndRemoveInternalZoneFrames(error, this);
- // use defineProperties here instead of copy property value
- // because of issue #595 which will break angular2.
- var props = getErrorPropertiesForPrototype(Object.getPrototypeOf(this));
- Object.defineProperties(this, props);
- return this;
+ attachZoneAndRemoveInternalZoneFrames(error);
+ return error;
}
// Copy the prototype so that instanceof operator works as expected
ZoneAwareError.prototype = NativeError.prototype;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
// 1. IE issue, the error.stack can only be not undefined after throw
// 2. handle Error(...) without new options
var throwError = function (message, withNew) {
- if (withNew === void 0) { withNew = true; }
- var error;
try {
if (withNew) {
throw new Error(message);
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
}
}
catch (err) {
- error = err;
+ return err;
}
- return error;
};
var nativeStackTraceLimit = NativeError.stackTraceLimit;
// in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
var detectRunFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames');
+ throw throwError('blacklistStackFrames', true);
});
});
};
var detectRunWithoutNewFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames', false);
+ throw throwError('blacklistStackFrames');
});
});
};
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
detectZoneWithCallbacks.runGuarded(detectPromiseCaughtWithoutNewFn);
NativeError.stackTraceLimit = nativeStackTraceLimit;
return global['Zone'] = Zone;
-})(typeof window === 'object' && window || typeof self === 'object' && self || global);
+})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
/**
* @license
@@ -1947,14 +1825,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
var tasksByHandleId = {};
function scheduleTask(task) {
var data = task.data;
- data.args[0] = function () {
+ function timer() {
try {
task.invoke.apply(this, arguments);
}
finally {
delete tasksByHandleId[data.handleId];
}
- };
+ }
+
+ data.args[0] = timer;
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;
diff --git a/dist/zone.js b/dist/zone.js
index 54ba94ce9..d402de2b0 100644
--- a/dist/zone.js
+++ b/dist/zone.js
@@ -280,7 +280,7 @@ var Zone$1 = (function (global) {
};
var ZoneDelegate = (function () {
function ZoneDelegate(zone, parentDelegate, zoneSpec) {
- this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 };
+ this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 };
this.zone = zone;
this._parentDelegate = parentDelegate;
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
@@ -919,112 +919,6 @@ var Zone$1 = (function (global) {
var zoneAwareErrorStartFrames = [];
global.Error = ZoneAwareError;
var stackRewrite = 'stackRewrite';
- // fix #595, create property descriptor
- // for error properties
- var createProperty = function (props, key) {
- // if property is already defined, skip it.
- if (props[key]) {
- return;
- }
- // define a local property
- // in case error property is not settable
- var name = __symbol__(key);
- props[key] = {
- configurable: true,
- enumerable: true,
- get: function () {
- // if local property has no value
- // use internal error's property value
- if (!this[name]) {
- var error_2 = this[__symbol__('error')];
- if (error_2) {
- this[name] = error_2[key];
- }
- }
- return this[name];
- },
- set: function (value) {
- // setter will set value to local property value
- this[name] = value;
- }
- };
- };
- // fix #595, create property descriptor
- // for error method properties
- var createMethodProperty = function (props, key) {
- if (props[key]) {
- return;
- }
- props[key] = {
- configurable: true,
- enumerable: true,
- writable: true,
- value: function () {
- var error = this[__symbol__('error')];
- var errorMethod = (error && error[key]) || this[key];
- if (errorMethod) {
- return errorMethod.apply(error, arguments);
- }
- }
- };
- };
- var createErrorProperties = function () {
- var props = Object.create(null);
- var error = new NativeError();
- var keys = Object.getOwnPropertyNames(error);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- // Avoid bugs when hasOwnProperty is shadowed
- if (Object.prototype.hasOwnProperty.call(error, key)) {
- createProperty(props, key);
- }
- }
- var proto = NativeError.prototype;
- if (proto) {
- var pKeys = Object.getOwnPropertyNames(proto);
- for (var i = 0; i < pKeys.length; i++) {
- var key = pKeys[i];
- // skip constructor
- if (key !== 'constructor' && key !== 'toString' && key !== 'toSource') {
- createProperty(props, key);
- }
- }
- }
- // some other properties are not
- // in NativeError
- createProperty(props, 'originalStack');
- createProperty(props, 'zoneAwareStack');
- // in IE, stack is not in prototype
- createProperty(props, 'stack');
- // define toString, toSource as method property
- createMethodProperty(props, 'toString');
- createMethodProperty(props, 'toSource');
- return props;
- };
- var errorProperties = createErrorProperties();
- // for derived Error class which extends ZoneAwareError
- // we should not override the derived class's property
- // so we create a new props object only copy the properties
- // from errorProperties which not exist in derived Error's prototype
- var getErrorPropertiesForPrototype = function (prototype) {
- // if the prototype is ZoneAwareError.prototype
- // we just return the prebuilt errorProperties.
- if (prototype === ZoneAwareError.prototype) {
- return errorProperties;
- }
- var newProps = Object.create(null);
- var cKeys = Object.getOwnPropertyNames(errorProperties);
- var keys = Object.getOwnPropertyNames(prototype);
- cKeys.forEach(function (cKey) {
- if (keys.filter(function (key) {
- return key === cKey;
- })
- .length === 0) {
- newProps[cKey] = errorProperties[cKey];
- }
- });
- return newProps;
- };
// some functions are not easily to be detected here,
// for example Timeout.ZoneTask.invoke, if we want to detect those functions
// by detect zone, we have to run all patched APIs, it is too risky
@@ -1033,7 +927,7 @@ var Zone$1 = (function (global) {
'ZoneTask.invoke', 'ZoneAware', 'getStacktraceWithUncaughtError', 'new LongStackTrace',
'long-stack-trace'
];
- function attachZoneAndRemoveInternalZoneFrames(error, zoneAwareError) {
+ function attachZoneAndRemoveInternalZoneFrames(error) {
// Save original stack trace
error.originalStack = error.stack;
// Process the stack trace and rewrite the frames.
@@ -1087,7 +981,6 @@ var Zone$1 = (function (global) {
catch (nonWritableErr) {
// in some browser, the error.stack is readonly such as PhantomJS
// so we need to store the stack frames to zoneAwareError directly
- zoneAwareError.stack = finalStack;
}
}
}
@@ -1096,14 +989,7 @@ var Zone$1 = (function (global) {
* adds zone information to it.
*/
function ZoneAwareError() {
- // make sure we have a valid this
- // if this is undefined(call Error without new) or this is global
- // or this is some other objects, we should force to create a
- // valid ZoneAwareError by call Object.create()
- if (!(this instanceof ZoneAwareError)) {
- return ZoneAwareError.apply(Object.create(ZoneAwareError.prototype), arguments);
- }
- // Create an Error.
+ // We always have to return native error otherwise the browser console will not work.
var error = NativeError.apply(this, arguments);
if (!error.stack) {
// in IE, the error.stack will be undefined
@@ -1116,15 +1002,10 @@ var Zone$1 = (function (global) {
error = err;
}
}
- this[__symbol__('error')] = error;
// 1. attach zone information to stack frame
// 2. remove zone internal stack frames
- attachZoneAndRemoveInternalZoneFrames(error, this);
- // use defineProperties here instead of copy property value
- // because of issue #595 which will break angular2.
- var props = getErrorPropertiesForPrototype(Object.getPrototypeOf(this));
- Object.defineProperties(this, props);
- return this;
+ attachZoneAndRemoveInternalZoneFrames(error);
+ return error;
}
// Copy the prototype so that instanceof operator works as expected
ZoneAwareError.prototype = NativeError.prototype;
@@ -1258,8 +1139,6 @@ var Zone$1 = (function (global) {
// 1. IE issue, the error.stack can only be not undefined after throw
// 2. handle Error(...) without new options
var throwError = function (message, withNew) {
- if (withNew === void 0) { withNew = true; }
- var error;
try {
if (withNew) {
throw new Error(message);
@@ -1269,9 +1148,8 @@ var Zone$1 = (function (global) {
}
}
catch (err) {
- error = err;
+ return err;
}
- return error;
};
var nativeStackTraceLimit = NativeError.stackTraceLimit;
// in some system/browser, some additional stack frames
@@ -1284,14 +1162,14 @@ var Zone$1 = (function (global) {
var detectRunFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames');
+ throw throwError('blacklistStackFrames', true);
});
});
};
var detectRunWithoutNewFn = function () {
detectZone.run(function () {
detectZone.runGuarded(function () {
- throw throwError('blacklistStackFrames', false);
+ throw throwError('blacklistStackFrames');
});
});
};
@@ -1440,7 +1318,7 @@ var Zone$1 = (function (global) {
detectZoneWithCallbacks.runGuarded(detectPromiseCaughtWithoutNewFn);
NativeError.stackTraceLimit = nativeStackTraceLimit;
return global['Zone'] = Zone;
-})(typeof window === 'object' && window || typeof self === 'object' && self || global);
+})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
/**
* @license
@@ -1849,14 +1727,16 @@ function patchTimer(window, setName, cancelName, nameSuffix) {
var tasksByHandleId = {};
function scheduleTask(task) {
var data = task.data;
- data.args[0] = function () {
+ function timer() {
try {
task.invoke.apply(this, arguments);
}
finally {
delete tasksByHandleId[data.handleId];
}
- };
+ }
+
+ data.args[0] = timer;
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;
@@ -2234,7 +2114,7 @@ function registerElementPatch(_global) {
var set = 'set';
var clear = 'clear';
var blockingMethods = ['alert', 'prompt', 'confirm'];
-var _global = typeof window === 'object' && window || typeof self === 'object' && self || global;
+var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global;
patchTimer(_global, set, clear, 'Timeout');
patchTimer(_global, set, clear, 'Interval');
patchTimer(_global, set, clear, 'Immediate');
diff --git a/dist/zone.min.js b/dist/zone.min.js
index 61d50fc36..6b3307c90 100644
--- a/dist/zone.min.js
+++ b/dist/zone.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";function e(e,t){for(var n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){for(var r=t.constructor.name,o=function(o){var a=n[o],i=t[a];i&&(t[a]=function(t){return function(){return t.apply(this,e(arguments,r+"."+a))}}(i))},a=0;a1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}function b(e){if(!j||D){var t="undefined"!=typeof WebSocket;w()?(C&&r(HTMLElement.prototype,W),r(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(r(IDBIndex.prototype,null),r(IDBRequest.prototype,null),r(IDBOpenDBRequest.prototype,null),r(IDBDatabase.prototype,null),r(IDBTransaction.prototype,null),r(IDBCursor.prototype,null)),t&&r(WebSocket.prototype,null)):(_(),c("XMLHttpRequest"),t&&m(e))}}function w(){if((C||D)&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"onreadystatechange");Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return!0}});var n=new XMLHttpRequest,r=!!n.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",t||{}),r}function _(){for(var e=function(e){var t=W[e],n="on"+t;self.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][X]&&(t=Zone.current.wrap(o[n],r),t[X]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t0?(n.splice(o,1),o--):t===te.transition?(r=r.parent?r.parent:null,n.splice(o,1),o--):n[o]+=" ["+r.zone.name+"]"}};o",this._properties=t&&t.properties||{},this._zoneDelegate=new C(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==Q)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return H.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return R},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},t.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),H=new I(H,this);try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{H=H.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),H=new I(H,this);try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{H=H.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||T).name+"; Execution: "+this.name+")");var r=e.state!=_;r&&e._transitionTo(_,w),e.runCount++;var o=R;R=e,H=new I(H,this);try{e.type==z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==m&&e.state!==E&&(e.type==P||e.data&&e.data.isPeriodic?r&&e._transitionTo(w,_):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(m,_,m))),H=H.parent,R=o}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,m);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(E,b,m),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(w,b),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new D(O,e,t,n,r,null))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new D(z,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new D(P,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||T).name+"; Execution: "+this.name+")");e._transitionTo(S,w,_);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,S),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(m,S),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),D=function(){function e(e,t,n,r,o,a){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=e,this.source=t,this.data=r,this.scheduleFn=o,this.cancelFn=a,this.callback=n;var u=this;this.invoke=function(){G++;try{return u.runCount++,u.zone.runTask(u,this,arguments)}finally{1==G&&i(),G--}}}return Object.defineProperty(e.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),e.prototype.cancelScheduleRequest=function(){this._transitionTo(m,b)},e.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==m&&(this._zoneDelegates=null)},e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},e.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,data:this.data,zone:this.zone.name,invoke:this.invoke,scheduleFn:this.scheduleFn,cancelFn:this.cancelFn,runCount:this.runCount,callback:this.callback}},e}(),I=function(){function e(e,t){this.parent=e,this.zone=t}return e}(),L=t("setTimeout"),M=t("Promise"),F=t("then"),H=new I(null,new Z(null,null)),R=null,x=[],A=!1,q=[],G=0,N=t("state"),B=t("value"),W="Promise.then",X=null,U=!0,K=!1,V=0,J=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},Q=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[N]=X,n[B]=[];try{t&&t(l(n,U),l(n,K))}catch(r){f(n,!1,r)}}return e.toString=function(){return"function ZoneAwarePromise() { [native code] }"},e.resolve=function(e){return f(new this(null),U,e)},e.reject=function(e){return f(new this(null),K,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){n=[e,t],r=n[0],o=n[1];var n}),i=0,s=e;i=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){for(var r=t.constructor.name,o=function(o){var a=n[o],i=t[a];i&&(t[a]=function(t){return function(){return t.apply(this,e(arguments,r+"."+a))}}(i))},a=0;a1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}function b(e){if(!D||j){var t="undefined"!=typeof WebSocket;w()?(P&&r(HTMLElement.prototype,W),r(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(r(IDBIndex.prototype,null),r(IDBRequest.prototype,null),r(IDBOpenDBRequest.prototype,null),r(IDBDatabase.prototype,null),r(IDBTransaction.prototype,null),r(IDBCursor.prototype,null)),t&&r(WebSocket.prototype,null)):(_(),c("XMLHttpRequest"),t&&m(e))}}function w(){if((P||j)&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"onreadystatechange");Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return!0}});var n=new XMLHttpRequest,r=!!n.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",t||{}),r}function _(){for(var e=function(e){var t=W[e],n="on"+t;self.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][X]&&(t=Zone.current.wrap(o[n],r),t[X]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t0?(t.splice(r,1),r--):o===te.transition?(n=n.parent?n.parent:null,t.splice(r,1),r--):t[r]+=" ["+n.zone.name+"]"}};r",this._properties=t&&t.properties||{},this._zoneDelegate=new P(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==Q)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return H.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return R},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},t.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),H=new I(H,this);try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{H=H.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),H=new I(H,this);try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{H=H.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||T).name+"; Execution: "+this.name+")");var r=e.state!=_;r&&e._transitionTo(_,w),e.runCount++;var o=R;R=e,H=new I(H,this);try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==m&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?r&&e._transitionTo(w,_):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(m,_,m))),H=H.parent,R=o}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,m);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,m),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(w,b),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new j(O,e,t,n,r,null))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new j(Z,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new j(z,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||T).name+"; Execution: "+this.name+")");e._transitionTo(E,w,_);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(m,E),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),j=function(){function e(e,t,n,r,o,a){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=e,this.source=t,this.data=r,this.scheduleFn=o,this.cancelFn=a,this.callback=n;var u=this;this.invoke=function(){G++;try{return u.runCount++,u.zone.runTask(u,this,arguments)}finally{1==G&&i(),G--}}}return Object.defineProperty(e.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),e.prototype.cancelScheduleRequest=function(){this._transitionTo(m,b)},e.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==m&&(this._zoneDelegates=null)},e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},e.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,data:this.data,zone:this.zone.name,invoke:this.invoke,scheduleFn:this.scheduleFn,cancelFn:this.cancelFn,runCount:this.runCount,callback:this.callback}},e}(),I=function(){function e(e,t){this.parent=e,this.zone=t}return e}(),L=t("setTimeout"),M=t("Promise"),F=t("then"),H=new I(null,new C(null,null)),R=null,x=[],A=!1,q=[],G=0,B=t("state"),N=t("value"),W="Promise.then",X=null,U=!0,K=!1,V=0,J=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},Q=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[B]=X,n[N]=[];try{t&&t(l(n,U),l(n,K))}catch(r){f(n,!1,r)}}return e.toString=function(){return"function ZoneAwarePromise() { [native code] }"},e.resolve=function(e){return f(new this(null),U,e)},e.reject=function(e){return f(new this(null),K,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){n=[e,t],r=n[0],o=n[1];var n}),i=0,s=e;i