/** * @author Toru Nagashima <https://github.com/mysticatea> * @copyright 2015 Toru Nagashima. All rights reserved. * See LICENSE file in root directory for full license. */(function(a,b){"object"==typeofexports&&"undefined"!=typeofmodule?b(exports):"function"==typeofdefine&&define.amd?define(["exports"],b):(a=a||self,b(a.EventTargetShim={}))})(this,function(a){"use strict";functionb(a){returnb="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(a){returntypeofa}:function(a){returna&&"function"==typeofSymbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeofa},b(a)}functionc(a){varb=u.get(a);returnconsole.assert(null!=b,"'this' is expected an Event object, but got",a),b}functiond(a){returnnull==a.passiveListener?void(!a.event.cancelable||(a.canceled=!0,"function"==typeofa.event.preventDefault&&a.event.preventDefault())):void("undefined"!=typeofconsole&&"function"==typeofconsole.error&&console.error("Unable to preventDefault inside passive event listener invocation.",a.passiveListener))}functione(a,b){u.set(this,{eventTarget:a,event:b,eventPhase:2,currentTarget:a,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:b.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(varc,d=Object.keys(b),e=0;e<d.length;++e)c=d[e],cinthis||Object.defineProperty(this,c,f(c))}functionf(a){return{get:function(){returnc(this).event[a]},set:function(b){c(this).event[a]=b},configurable:!0,enumerable:!0}}functiong(a){return{value:function(){varb=c(this).event;returnb[a].apply(b,arguments)},configurable:!0,enumerable:!0}}functionh(a,b){functionc(b,c){a.call(this,b,c)}vard=Object.keys(b);if(0===d.length)returna;c.prototype=Object.create(a.prototype,{constructor:{value:c,configurable:!0,writable:!0}});for(vare,h=0;h<d.length;++h)if(e=d[h],!(eina.prototype)){varj=Object.getOwnPropertyDescriptor(b,e),k="function"==typeofj.value;Object.defineProperty(c.prototype,e,k?g(e):f(e))}returnc}functioni(a){if(null==a||a===Object.prototype)returne;varb=v.get(a);returnnull==b&&(b=h(i(Object.getPrototypeOf(a)),a),v.set(a,b)),b}functionj(a,b){varc=i(Object.getPrototypeOf(b));returnnewc(a,b)}functionk(a){returnc(a).immediateStopped}functionl(a,b){c(a).eventPhase=b}functionm(a,b){c(a).currentTarget=b}functionn(a,b){c(a).passiveListener=b}functiono(a){returnnull!==a&&"object"===b(a)}functionp(a){varb=w.get(a);if(null==b)thrownewTypeError("'this' is expected an EventTarget object, but got another value.");returnb}functionq(a){return{get:function(){for(varb=p(this),c=b.get(a);null!=c;){if(3===c.listenerType)returnc.listener;c=c.next}returnnull},set:function(b){"function"==typeofb||o(b)||(b=null);for(varc=p(this),d=null,e=c.get(a);null!=e;)3===e.listenerType?null===d?null===e.next?c.delete(a):c.set(a,e.next):d.next=e.next:d=e,e=e.next;if(null!==b){varf={listener:b,listenerType:3,passive:!1,once:!1,next:null};null===d?c.set(a,f):d.next=f}},configurable:!0,enumerable:!0}}functionr(a,b){Object.defineProperty(a,"on".concat(b),q(b))}functions(a){functionb(){t.call(this)}b.prototype=Object.create(t.prototype,{constructor:{value:b,configurable:!0,writable:!0}});for(varc=0;c<a.length;++c)r(b.prototype,a[c]);returnb}functiont(){if(thisinstanceoft)returnvoidw.set(this,newMap);if(1===arguments.length&&Array.isArray(arguments[0]))returns(arguments[0]);if(0<arguments.length){for(vara=Array(arguments.length),b=0;b<arguments.length;++b)a[b]=arguments[b];returns(a)}thrownewTypeError("Cannot call a class as a function")}varu=newWeakMap,v=newWeakMap;e.prototype={gettype(){returnc(this).event.type},gettarget(){returnc(this).eventTarget},getcurrentTarget(){returnc(this).currentTarget},composedPath:function(){vara=c(this).currentTarget;returnnull==a?[]:[a]},getNONE(){return0},getCAPTURING_PHASE(){return1},getAT_TARGET(){return2},getBUBBLING_PHASE(){return3},geteventPhase(){returnc(this).eventPhase},stopPropagation:function(){vara=c(this);a.stopped=!0,"function"==typeofa.event.stopPropagation&&a.event.stopPropagation()},stopImmediatePropagation:function(){vara=c(this);a.stopped=!0,a.immediateStopped=!0,"function"==typeofa.event.stopImmediatePropagation&&a.event.stopImmediatePropagation()},getbubbles(){return!!c(this).event.bubbles},getcancelable(){return!!c(this).event.cancelable},preventDefault:function(){d(c(this))},getdefaultPrevented(){returnc(this).canceled},getcomposed(){return!!c(this).event.composed},gettimeStamp(){returnc(this).timeStamp},getsrcElement(){returnc(this).eventTarget},getcancelBubble(){returnc(this).stopped},setcancelBubble(a){if(a){varb=c(this);b.stopped=!0,"boolean"==typeofb.event.cancelBubble&&(b.event.cancelBubble=!0)}},getreturnValue(){return!c(this).canceled},setreturnValue(a){a||d(c(this))},initEvent:function(){}},Object.defineProperty(e.prototype,"constructor",{value:e,configurable:!0,writable:!0}),"undefined"!=typeofwindow&&"undefined"!=typeofwindow.Event&&(Object.setPrototypeOf(e.prototype,window.Event.prototype),v.set(window.Event.prototype,e));varw=newWeakMap,x=1,y=2;if(t.prototype={addEventListener:function(a,b,c){if(null!=b){if("function"!=typeofb&&!o(b))thrownewTypeError("'listener' should be a function or an object.");vard=p(this),e=o(c),f=e?!!c.capture:!!c,g=f?x:y,h={listener:b,listenerType:g,passive:e&&!!c.passive,once:e&&!!c.once,next:null},i=d.get(a);if(void0===i)returnvoidd.set(a,h);for(varj=null;null!=i;){if(i.listener===b&&i.listenerType===g)return;j=i,i=i.next}j.next=h}},removeEventListener:function(a,b,c){if(null!=b)for(vard=p(this),e=o(c)?!!c.capture:!!c,f=e?x:y,g=null,h=d.get(a);null!=h;){if(h.listener===b&&h.listenerType===f)returnvoid(null===g?null===h.next?d.delete(a):d.set(a,h.next):g.next=h.next);g=h,h=h.next}},dispatchEvent:function(a){if(null==a||"string"!=typeofa.type)thrownewTypeError("\"event.type\" should be a string.");varb=p(this),c=a.type,d=b.get(c);if(null==d)return!0;for(vare=j(this,a),f=null;null!=d;){if(d.once?null===f?null===d.next?b.delete(c):b.set(c,d.next):f.next=d.next:f=d,n(e,d.passive?d.listener:null),"function"==typeofd.listener)try{d.listener.call(this,e)}catch(a){"undefined"!=typeofconsole&&"function"==typeofconsole.error&&console.error(a)}elsed.listenerType!==3&&"function"==typeofd.listener.handleEvent&&d.listener.handleEvent(e);if(k(e))break;d=d.next}returnn(e,null),l(e,0),m(e,null),!e.defaultPrevented}},Object.defineProperty(t.prototype,"constructor",{value:t,configurable:!0,writable:!0}),"undefined"!=typeofwindow&&"undefined"!=typeofwindow.EventTarget&&Object.setPrototypeOf(t.prototype,window.EventTarget.prototype),a.defineEventAttribute=r,a.EventTarget=t,a.default=t,Object.defineProperty(a,"__esModule",{value:!0}),"undefined"==typeofmodule&&"undefined"==typeofdefine){varz=Function("return this")();z.EventTargetShim=t,z.EventTargetShim.defineEventAttribute=r}});//# sourceMappingURL=event-target-shim.umd.js.map