UNPKG

2.94 kBJavaScriptView Raw
1/*
2Copyright (c) NAVER Corp.
3name: @egjs/component
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-component
7version: 3.0.1
8*/
9!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Component=n()}(this,function(){"use strict";function l(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),f=[];try{for(;(void 0===n||0<n--)&&!(r=i.next()).done;)f.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return f}(arguments[n]));return t}function h(t){return void 0===t}var i=function(){function t(t,n){var e,r;if(this.eventType=t,this._canceled=!1,n)try{for(var o=l(Object.keys(n)),i=o.next();!i.done;i=o.next()){var f=i.value;this[f]=n[f]}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}}var n=t.prototype;return n.stop=function(){this._canceled=!0},n.isCanceled=function(){return this._canceled},t}(),t=function(){function t(){this._eventHandler={}}var n=t.prototype;return n.trigger=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var r=n instanceof i?n.eventType:n,o=f(this._eventHandler[r]||[]);return o.length<=0||(n instanceof i?(n.currentTarget=this,o.forEach(function(t){t(n)})):o.forEach(function(t){t.apply(void 0,f(e))})),this},n.once=function(e,r){var o,i=this;if("object"==typeof e&&h(r)){var t,n=e;for(t in n)this.once(t,n[t]);return this}return"string"==typeof e&&"function"==typeof r&&(o=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.apply(void 0,f(t)),i.off(e,o)},this.on(e,o)),this},n.hasOn=function(t){return!!this._eventHandler[t]},n.on=function(t,n){if("object"==typeof t&&h(n)){var e,r=t;for(e in r)this.on(e,r[e]);return this}var o;return"string"==typeof t&&"function"==typeof n&&(o=this._eventHandler[t],h(o)&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(n)),this},n.off=function(t,n){var e,r;if(h(t))return this._eventHandler={},this;if(h(n)){if("string"==typeof t)return delete this._eventHandler[t],this;var o,i=t;for(o in i)this.off(o,i[o]);return this}var f=this._eventHandler[t];if(f){var a=0;try{for(var u=l(f),c=u.next();!c.done;c=u.next()){if(c.value===n){f.splice(a,1),f.length<=0&&delete this._eventHandler[t];break}a++}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}}return this},t.VERSION="3.0.1",t}();return t.ComponentEvent=i,t});
10//# sourceMappingURL=component.min.js.map