diff --git a/dist/zone-evergreen-testing-bundle.js b/dist/zone-evergreen-testing-bundle.js index da3dce583..e418059af 100644 --- a/dist/zone-evergreen-testing-bundle.js +++ b/dist/zone-evergreen-testing-bundle.js @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone-evergreen.js b/dist/zone-evergreen.js index 6666bf1cb..5988732ee 100644 --- a/dist/zone-evergreen.js +++ b/dist/zone-evergreen.js @@ -1587,7 +1587,7 @@ function patchEventTarget(_global, apis, patchOptions) { const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; const PREPEND_EVENT_LISTENER = 'prependListener'; const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - const invokeTask = function (task, target, event) { + const invokeTask = function (task, target, event, mergeCallback = false) { // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1600,7 +1600,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } const options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1628,17 +1633,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener const copyTasks = tasks.slice(); - for (let i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + const mergedCallback = function () { + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + const mergedTask = Object.create(copyTasks[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone-evergreen.min.js b/dist/zone-evergreen.min.js index 7d044141c..eacedaea0 100644 --- a/dist/zone-evergreen.min.js +++ b/dist/zone-evergreen.min.js @@ -1 +1 @@ -const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;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(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(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==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const t=e&&e.rejection;t?console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0):console.error(e)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const s=e.options;if(s&&"object"==typeof s&&s.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,s)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}patchFilteredProperties(XMLHttpRequest.prototype,XMLHttpRequestEventNames,o);const r=t.XMLHttpRequestEventTarget;r&&patchFilteredProperties(r&&r.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!n&&!o||!("customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=XMLHttpRequest.prototype;let l=c[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=c[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!l){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;l=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const p="readystatechange",h="scheduled";function f(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];l||(l=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&u.call(o,p,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===h){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],m.apply(e,t)})),g=zoneSymbol("fetchTaskAborting"),y=zoneSymbol("fetchTaskScheduling"),E=patchMethod(c,"send",()=>(function(e,n){if(!0===t.current[y])return E.apply(e,n);if(e[o])return E.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",d,t,f,_);e&&!0===e[a]&&!t.aborted&&o.state===h&&o.invoke()}})),b=patchMethod(c,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[g])return b.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file +const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;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(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(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==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const t=e&&e.rejection;t?console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0):console.error(e)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n,o=!1){if(e.isRemoved)return;const s=e.callback;"object"==typeof s&&s.handleEvent&&(e.callback=(e=>s.handleEvent(e)),e.originalDelegate=s),o?e.callback.call(t,n):e.invoke(e,t,[n]);const i=e.options;if(i&&"object"==typeof i&&i.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,i)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else if(o.length>1){const e=o.slice(),r=function(){for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}patchFilteredProperties(XMLHttpRequest.prototype,XMLHttpRequestEventNames,o);const r=t.XMLHttpRequestEventTarget;r&&patchFilteredProperties(r&&r.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!n&&!o||!("customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=XMLHttpRequest.prototype;let l=c[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=c[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!l){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;l=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const p="readystatechange",h="scheduled";function f(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];l||(l=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&u.call(o,p,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===h){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],m.apply(e,t)})),g=zoneSymbol("fetchTaskAborting"),y=zoneSymbol("fetchTaskScheduling"),E=patchMethod(c,"send",()=>(function(e,n){if(!0===t.current[y])return E.apply(e,n);if(e[o])return E.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",d,t,f,_);e&&!0===e[a]&&!t.aborted&&o.state===h&&o.invoke()}})),b=patchMethod(c,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[g])return b.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file diff --git a/dist/zone-mix.js b/dist/zone-mix.js index df2cc402c..f29b8db6a 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -1682,7 +1682,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1695,7 +1696,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1723,17 +1729,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone-node.js b/dist/zone-node.js index 9f90c8cd6..4cf788bca 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -1596,7 +1596,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1609,7 +1610,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1637,17 +1643,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index d860dc392..a0b7296b2 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 1114a410a..39fccd799 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -1596,7 +1596,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1609,7 +1610,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1637,17 +1643,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone.js b/dist/zone.js index f812a3b72..106bd89ac 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -1677,7 +1677,8 @@ function patchEventTarget(_global, apis, patchOptions) { var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { + var invokeTask = function (task, target, event, mergeCallback) { + if (mergeCallback === void 0) { mergeCallback = false; } // for better performance, check isRemoved which is set // by removeEventListener if (task.isRemoved) { @@ -1690,7 +1691,12 @@ function patchEventTarget(_global, apis, patchOptions) { task.originalDelegate = delegate; } // invoke static task.invoke - task.invoke(task, target, [event]); + if (mergeCallback) { + task.callback.call(target, event); + } + else { + task.invoke(task, target, [event]); + } var options = task.options; if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here @@ -1718,17 +1724,22 @@ function patchEventTarget(_global, apis, patchOptions) { if (tasks.length === 1) { invokeTask(tasks[0], target, event); } - else { + else if (tasks.length > 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var copyTasks_1 = tasks.slice(); + var mergedCallback = function () { + for (var i = 0; i < copyTasks_1.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks_1[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + var mergedTask = Object.create(copyTasks_1[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/dist/zone.min.js b/dist/zone.min.js index 3c96665e7..6d4093237 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";!function(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(o||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var a,i=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new c(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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 Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var s="Zone:"+a;n(s),P[a]=i(e,t,D),r(s,s)}},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){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.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||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==O&&e.type!==S){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==S&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==O||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=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(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,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||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===O&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.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==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,s=[],c=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){var t=e&&e.rejection;t?console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0):console.error(e)}},r.microtaskDrainDone=function(){for(;s.length;)for(var e=function(){var e=s.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};s.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,S=0;function O(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var c=null;try{"object"!=typeof o&&"function"!=typeof o||(c=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof c)try{c.call(o,i(O(e,t)),i(O(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),S=!w&&!E&&!(!g||!y.HTMLElement),O=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(S&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var s=a.get,c=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),c&&c.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(s){var o=s&&s.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var s=e[o];if(s)return t.call(s)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},q={},W={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||s,c=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;if(o&&"object"==typeof o&&o.once){var i=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,i,o)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[q[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(c,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(c),s=c,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var s=Zone.__symbol__("ON_PROPERTY"+a);c[s]=i[s]}}return c[t].apply(c,n)}})):i=c,e.patchOnProperties(i,["close","error","message","open"],s),i};var i=t.WebSocket;for(var s in a)i[s]=a[s]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}Zone.__load_patch("util",function(e,r,c){c.patchOnProperties=j,c.patchMethod=R,c.bindArguments=k,c.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),c.patchEventPrototype=K,c.patchEventTarget=V,c.isIEOrEdge=H,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=a,c.patchClass=C,c.wrapWithCurrentZone=h,c.filterProperties=ye,c.attachOriginToPatched=M,c._redefineProperty=re,c.patchCallbacks=J,c.getGlobalObjects=function(){return{globalSources:W,zoneSymbolEventNames:q,eventNames:ge,isBrowser:S,isMix:O,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:s}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,o=n.globalSources,a=n.zoneSymbolEventNames,i=n.TRUE_STR,s=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,l="Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video",u="ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex,WebSocket".split(","),f=[],p=e.wtf,h=l.split(",");p?f=h.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(f=u);for(var d=e.__Zone_disable_IE_check||!1,v=e.__Zone_enable_cross_context_check||!1,g=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",_=0;_0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a",this._properties=t&&t.properties||{},this._zoneDelegate=new c(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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 Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var s="Zone:"+a;n(s),P[a]=i(e,t,D),r(s,s)}},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){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.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||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==S&&e.type!==O){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==S||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=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(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,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||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===S&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.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==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,s=[],c=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){var t=e&&e.rejection;t?console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0):console.error(e)}},r.microtaskDrainDone=function(){for(;s.length;)for(var e=function(){var e=s.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};s.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,O=0;function S(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var c=null;try{"object"!=typeof o&&"function"!=typeof o||(c=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof c)try{c.call(o,i(S(e,t)),i(S(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),O=!w&&!E&&!(!g||!y.HTMLElement),S=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(O&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var s=a.get,c=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),c&&c.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(s){var o=s&&s.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var s=e[o];if(s)return t.call(s)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},q={},W={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||s,c=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n,r){if(void 0===r&&(r=!1),!e.isRemoved){var o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=function(e){return o.handleEvent(e)},e.originalDelegate=o),r?e.callback.call(t,n):e.invoke(e,t,[n]);var i=e.options;if(i&&"object"==typeof i&&i.once){var s=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,s,i)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[q[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else if(r.length>1){var o=r.slice(),a=Object.create(o[0]);a.callback=function(){for(var e=0;e1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(c,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(c),s=c,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var s=Zone.__symbol__("ON_PROPERTY"+a);c[s]=i[s]}}return c[t].apply(c,n)}})):i=c,e.patchOnProperties(i,["close","error","message","open"],s),i};var i=t.WebSocket;for(var s in a)i[s]=a[s]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}Zone.__load_patch("util",function(e,r,c){c.patchOnProperties=j,c.patchMethod=R,c.bindArguments=k,c.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),c.patchEventPrototype=K,c.patchEventTarget=V,c.isIEOrEdge=H,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=a,c.patchClass=C,c.wrapWithCurrentZone=h,c.filterProperties=ye,c.attachOriginToPatched=M,c._redefineProperty=re,c.patchCallbacks=J,c.getGlobalObjects=function(){return{globalSources:W,zoneSymbolEventNames:q,eventNames:ge,isBrowser:O,isMix:S,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:s}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,o=n.globalSources,a=n.zoneSymbolEventNames,i=n.TRUE_STR,s=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,l="Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video",u="ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex,WebSocket".split(","),f=[],p=e.wtf,h=l.split(",");p?f=h.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(f=u);for(var d=e.__Zone_disable_IE_check||!1,v=e.__Zone_enable_cross_context_check||!1,g=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",_=0;_0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a 1) { // https://github.com/angular/zone.js/issues/836 // copy the tasks array before invoke, to avoid // the callback will remove itself or other listener const copyTasks = tasks.slice(); - for (let i = 0; i < copyTasks.length; i++) { - if (event && (event as any)[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + const mergedCallback = function() { + for (let i = 0; i < copyTasks.length; i++) { + if (event && (event as any)[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + return; + } + invokeTask(copyTasks[i], target, event, true); } - invokeTask(copyTasks[i], target, event); - } + }; + const mergedTask = Object.create(copyTasks[0]); + mergedTask.callback = mergedCallback; + invokeTask(mergedTask, target, event); } } }; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index a74f3683f..ad438dac9 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -448,6 +448,40 @@ describe('Zone', function() { expect(eventListenerSpy).toHaveBeenCalled(); }); + it('should support addEventListener multiple times with different listeners but only trigger hook once', + function() { + const scheduleSpy = jasmine.createSpy('schedule'); + const invokeSpy = jasmine.createSpy('invoke'); + const eventListenerSpy1 = jasmine.createSpy('eventListener1'); + const eventListenerSpy2 = jasmine.createSpy('eventListener2'); + const zone = rootZone.fork({ + name: 'spy', + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + scheduleSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onInvokeTask: + (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) => { + invokeSpy(); + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + }); + + zone.run(function() { + button.addEventListener('click', eventListenerSpy1); + button.addEventListener('click', eventListenerSpy2); + }); + + button.dispatchEvent(clickEvent); + + expect(scheduleSpy.calls.count()).toBe(2); + expect(invokeSpy.calls.count()).toBe(1); + expect(eventListenerSpy1).toHaveBeenCalled(); + expect(eventListenerSpy2).toHaveBeenCalled(); + }); + it('should be able to access addEventListener information in onScheduleTask', function() { const hookSpy = jasmine.createSpy('hook'); const eventListenerSpy = jasmine.createSpy('eventListener');