2 lines
4.9 KiB
JavaScript
2 lines
4.9 KiB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.eventTargetShim=e()}}(function(){return function e(t,n,r){function o(i,u){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!u&&l)return l(i,!0);if(a)return a(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[i]={exports:{}};t[i][0].call(c.exports,function(e){var n=t[i][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t,n){"use strict";var r=n.createUniqueKey="undefined"!=typeof Symbol?Symbol:function(e){return"[["+e+"_"+Math.random().toFixed(8).slice(2)+"]]"};n.LISTENERS=r("listeners"),n.CAPTURE=1,n.BUBBLE=2,n.ATTRIBUTE=3,n.newNode=function(e,t){return{listener:e,kind:t,next:null}}},{}],2:[function(e,t,n){"use strict";function r(e,t){for(var n=e[i][t];null!=n;){if(n.kind===u)return n.listener;n=n.next}return null}function o(e,t,n){"function"!=typeof n&&"object"!=typeof n&&(n=null);for(var r=null,o=e[i][t];null!=o;)o.kind===u?null==r?e[i][t]=o.next:r.next=o.next:r=o,o=o.next;null!=n&&(null==r?e[i][t]=l(n,u):r.next=l(n,u))}var a=e("./commons"),i=a.LISTENERS,u=a.ATTRIBUTE,l=a.newNode;n.defineCustomEventTarget=function(e,t){function n(){e.call(this)}var a={constructor:{value:n,configurable:!0,writable:!0}};return t.forEach(function(e){a["on"+e]={get:function(){return r(this,e)},set:function(t){o(this,e,t)},configurable:!0,enumerable:!0}}),n.prototype=Object.create(e.prototype,a),n}},{"./commons":1}],3:[function(e,t,n){"use strict";var r=e("./commons"),o=e("./custom-event-target"),a=e("./event-wrapper"),i=r.LISTENERS,u=r.CAPTURE,l=r.BUBBLE,f=r.ATTRIBUTE,c=r.newNode,s=o.defineCustomEventTarget,p=a.createEventWrapper,v=a.STOP_IMMEDIATE_PROPAGATION_FLAG,d="undefined"!=typeof window&&"undefined"!=typeof window.EventTarget,b=t.exports=function m(){if(!(this instanceof m)){if(1===arguments.length&&Array.isArray(arguments[0]))return s(m,arguments[0]);if(arguments.length>0){for(var e=Array(arguments.length),t=0;t<arguments.length;++t)e[t]=arguments[t];return s(m,e)}throw new TypeError("Cannot call a class as a function")}Object.defineProperty(this,i,{value:Object.create(null)})};b.prototype=Object.create((d?window.EventTarget:Object).prototype,{constructor:{value:b,writable:!0,configurable:!0},addEventListener:{value:function(e,t,n){if(null==t)return!1;if("function"!=typeof t&&"object"!=typeof t)throw new TypeError('"listener" is not an object.');var r=n?u:l,o=this[i][e];if(null==o)return this[i][e]=c(t,r),!0;for(var a=null;null!=o;){if(o.listener===t&&o.kind===r)return!1;a=o,o=o.next}return a.next=c(t,r),!0},configurable:!0,writable:!0},removeEventListener:{value:function(e,t,n){if(null==t)return!1;for(var r=n?u:l,o=null,a=this[i][e];null!=a;){if(a.listener===t&&a.kind===r)return null==o?this[i][e]=a.next:o.next=a.next,!0;o=a,a=a.next}return!1},configurable:!0,writable:!0},dispatchEvent:{value:function(e){var t=this[i][e.type];if(null==t)return!0;for(var n=p(e,this);null!=t&&("function"==typeof t.listener?t.listener.call(this,n):t.kind!==f&&"function"==typeof t.listener.handleEvent&&t.listener.handleEvent(n),!n[v]);)t=t.next;return!n.defaultPrevented},configurable:!0,writable:!0}})},{"./commons":1,"./custom-event-target":2,"./event-wrapper":4}],4:[function(e,t,n){"use strict";var r=e("./commons").createUniqueKey,o=r("stop_immediate_propagation_flag"),a=r("canceled_flag"),i=r("original_event"),u=Object.freeze({stopPropagation:Object.freeze({value:function(){var e=this[i];"function"==typeof e.stopPropagation&&e.stopPropagation()},writable:!0,configurable:!0}),stopImmediatePropagation:Object.freeze({value:function(){this[o]=!0;var e=this[i];"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()},writable:!0,configurable:!0}),preventDefault:Object.freeze({value:function(){this.cancelable===!0&&(this[a]=!0);var e=this[i];"function"==typeof e.preventDefault&&e.preventDefault()},writable:!0,configurable:!0}),defaultPrevented:Object.freeze({get:function(){return this[a]},enumerable:!0,configurable:!0})});n.STOP_IMMEDIATE_PROPAGATION_FLAG=o,n.createEventWrapper=function(e,t){var n="number"==typeof e.timeStamp?e.timeStamp:Date.now(),r={type:{value:e.type,enumerable:!0},target:{value:t,enumerable:!0},currentTarget:{value:t,enumerable:!0},eventPhase:{value:2,enumerable:!0},bubbles:{value:Boolean(e.bubbles),enumerable:!0},cancelable:{value:Boolean(e.cancelable),enumerable:!0},timeStamp:{value:n,enumerable:!0},isTrusted:{value:!1,enumerable:!0}};return r[o]={value:!1,writable:!0},r[a]={value:!1,writable:!0},r[i]={value:e},"undefined"!=typeof e.detail&&(r.detail={value:e.detail,enumerable:!0}),Object.create(Object.create(e,u),r)}},{"./commons":1}]},{},[3])(3)});
|