-
Notifications
You must be signed in to change notification settings - Fork 0
/
delegate.min.js.map
1 lines (1 loc) · 87.3 KB
/
delegate.min.js.map
1
{"version":3,"file":"delegate.min.js","sources":["createEvent.js","utils/isString.js","utils/isElement.js","getListeners.js","enum.js","_off.js","_delete.js","purgeElement.js","utils/isFunction.js","utils/_typeof.js","off.js","at.js","matches.js","getParentOrHost.js","resolveTextNode.js","getTarget.js","on.js","closest.js","utils/isIE.js","getTypes.js","getScroll.js","getPageX.js","getScrollLeft.js","getPageY.js","getScrollTop.js","getCharCode.js","utils/isAppleSafari.js","preventDefault.js","stopPropagation.js","stopEvent.js","emitter.js","hasEvent.js","getPageXY.js","getRelatedTarget.js","destroy.js","only.js","once.js","focusin.js","focusout.js","trigger.js","stopImmediate.js","delegate.js"],"sourcesContent":["/**\n * 创建自定义事件(CustomerEvent)\n * ========================================================================\n * @method createEvent\n * @param {String} type - (必须)事件类型(名称)\n * @param {Object} [detail] - (可选)传递给自定义事件的数据,默认为 null\n * @param {Boolean} [bubbles] - (可选)是否支持冒泡,默认为 true\n * @param {Boolean} [cancelable] - (可选)是否可以取消,默认为 true\n * @returns {CustomEvent} - CustomerEvent 实例\n *\n * @example\n * <div id=\"nav\" class=\"nav\">\n * <a id=\"service\" class=\"anchor\" href=\"https://www.yaohaixiao.com/serivce\">Service</a>\n * <a id=\"help\" class=\"anchor\" href=\"https://www.yaohaixiao.com/help\">Help</a>\n * </div>\n *\n * const $nav = document.querySelector('#nav')\n * const logEvent = createEvent('log', {\n * name: 'Yao',\n * hi() {\n * console.log('hi!!!')\n * }\n * })\n *\n * const logHandler = function(evt) {\n * console.log('detail', evt.detail)\n * console.log('type', evt.type)\n * }\n *\n * $nav.addEventListener('log', logHandler)\n *\n * $nav.dispatchEvent(logEvent)\n */\nconst createEvent = (\n type,\n detail = null,\n bubbles = true,\n cancelable = true\n) => {\n return new CustomEvent(type, {\n detail: detail,\n bubbles: bubbles,\n cancelable: cancelable\n })\n}\n\nexport default createEvent\n","/**\n * 判断是否为 String 类型值\n * ========================================================================\n * @method isString\n * @param {*} val - (必须)待检测的字符串\n * @returns {Boolean}\n */\nconst isString = (val) => {\n return typeof val === 'string'\n}\n\nexport default isString\n","/**\n * 检测是否为 HTMLElement 元素节点\n * ========================================================================\n * @method isElement\n * @param {*|HTMLElement} el - (必须)待检测的数据(DOM 元素)\n * @returns {Boolean}\n */\nconst isElement = (el) => {\n return !!(el && el.nodeName && el.tagName && el.nodeType === 1)\n}\n\nexport default isElement\n","import isString from './utils/isString'\n\n/**\n * 获取 DOM 元素(type 事件类型)事件绑定信息\n * ========================================================================\n * 如果设置了事件类型 type, 则返回指定类型的事件绑定信息,否则返回所有事件绑定信息\n * ========================================================================\n * @methods getListeners\n * @param {HTMLElement} el - (必须)要获取事件绑定信息的 DOM 元素\n * @param {String} [type] - (可选)事件类型\n * @returns {Array} - 已绑定的事件信息\n */\nconst getListeners = (el, type) => {\n let listeners = el._listeners || []\n\n if (isString(type) && type) {\n listeners = listeners.filter((listener) => {\n return listener.type === type\n })\n }\n\n return listeners\n}\n\nexport default getListeners\n","export const CAPTURE_EVENTS = [\n 'focusout',\n 'blur',\n 'focusin',\n 'focus',\n 'load',\n 'unload',\n 'mouseenter',\n 'mouseleave'\n]\n","import { CAPTURE_EVENTS } from './enum'\nimport _delete from './_delete'\n\n/**\n * (私有方法)取消 type 类型的代理事件绑定\n * ========================================================================\n * 如果没有设置 handler,则销毁 this.$options 绑定的所有符合 type 事件类型的事件绑定\n * ========================================================================\n * @method _off\n * @param {HTMLElement} el - (必须)取消事件绑定的 DOM 元素\n * @param {String} type - (必须)事件类型\n * @param {Function} fn - (必须)事件处理器回调函数\n * @private\n */\nconst _off = (el, type, fn) => {\n const capture = CAPTURE_EVENTS.indexOf(type) > -1\n\n /* istanbul ignore else */\n if (fn._delegateListener) {\n fn = fn._delegateListener\n delete fn._delegateListener\n }\n\n // 移除缓存的 _listeners 数据\n _delete(el, type, fn)\n\n el.removeEventListener(type, fn, capture)\n}\n\nexport default _off\n","/**\n * 删除 DOM 元素缓存的 _listeners 数据\n * ========================================================================\n * @method _delete\n * @param {HTMLElement} el - 要删除 listener 的 DOM 元素\n * @param {String} type - 事件类型(名称)\n * @param {Function} [fn] - 事件处理器回调函数\n */\nconst _delete = function (el, type, fn) {\n const listeners = el._listeners\n let index = -1\n\n if (listeners.length < 1) {\n return false\n }\n\n // 移除缓存的 _listeners 数据\n listeners.forEach((listener, i) => {\n const handler = listener.fn\n\n if (type === listener.type) {\n index = i\n\n if (handler === fn) {\n index = i\n }\n }\n })\n\n /* istanbul ignore else */\n if (index > -1) {\n listeners.splice(index, 1)\n }\n}\n\nexport default _delete\n","import isString from './utils/isString'\nimport isElement from './utils/isElement'\nimport getListeners from './getListeners'\nimport _off from './_off'\n\n/**\n * 销毁(type 类型的)代理事件绑定\n * ========================================================================\n * 1. 设置了事件类型 type,则销毁指定类型的事件绑定,否则清除所有代理事件绑定\n * 2. recurse 设置为 true,递归销毁子节点全部事件绑定\n * ========================================================================\n * @method purgeElement\n * @param {HTMLElement|String} el - (必须)DOM 元素或者其选择器\n * @param {String|Boolean} type - (必须)事件类型\n * @param {Boolean} [recurse] - (可选)是否递归销毁子节点所有事件绑定\n */\nconst purgeElement = function (el, type, recurse = false) {\n const $element = isString(el) ? document.querySelector(el) : el\n const $children = $element.childNodes\n const listeners = getListeners($element, type)\n\n listeners.forEach((listener) => {\n _off($element, listener.type, listener.fn)\n })\n\n if (\n (recurse || type === true || arguments.length === 1) &&\n $element &&\n $children\n ) {\n $children.forEach(($child) => {\n if (isElement($child)) {\n purgeElement($child, type, recurse)\n }\n })\n }\n}\n\nexport default purgeElement\n","import _typeof from './_typeof'\n\n/**\n * 检测测试数据是否为 Function 类型\n * ========================================================================\n * @method isFunction\n * @param {*} val - (必须)待检测的数据\n * @returns {boolean} 'val' 是 Function 类型返回 true,否则返回 false\n */\nconst isFunction = (val) => {\n return typeof val === 'function' || _typeof(val) === '[object Function]'\n}\n\nexport default isFunction\n","/**\n * 返回检测数据调用 toString() 方法后的字符串,用以判断数据类型。\n * ========================================================================\n * @method _typeof\n * @param {*} val - (必须)待检测的数据\n * @returns {String}\n *\n * @example\n * _typeof({})\n * // => '[object Object]'\n *\n * _typeof(function(){})\n * // => '[object Function]'\n *\n * _typeof([])\n * // => '[object Array]'\n *\n * _typeof('')\n * // => '[object String]'\n *\n * _typeof(2)\n * // => '[object Number]'\n */\nconst _typeof = (val) => {\n return Object.prototype.toString.apply(val)\n}\n\nexport default _typeof\n","import purgeElement from './purgeElement'\nimport isFunction from './utils/isFunction'\nimport _off from './_off'\n\n/**\n * 取消 type 类型的代理事件绑定\n * ========================================================================\n * 如果没有设置 handler,则销毁 this.$options 绑定的所有符合 type 事件类型的事件绑定\n * ========================================================================\n * @method off\n * @param {HTMLElement} el - (必须)取消事件绑定的 DOM 元素\n * @param {String} type - (必须)事件类型\n * @param {Function} [fn] - (可选)事件处理器回调函数\n */\nconst off = (el, type, fn) => {\n // 如果不设置 fn 参数,默认清除 el 元素上绑定的所有事件处理器\n if (!isFunction(fn)) {\n return purgeElement(el, type)\n }\n\n _off(el, type, fn)\n}\n\nexport default off\n","import isFunction from './utils/isFunction'\nimport off from './off'\n\nimport { CAPTURE_EVENTS } from './enum'\n\n/**\n * 绑定事件\n * ========================================================================\n * @method at\n * @param {HTMLElement|String|Object} el - (必须)绑定代理事件的 DOM 节点\n * @param {String|Function} type - (必须)事件类型或者事件处理器回调函数\n * @param {Function|Object} fn - (必须) 事件处理器回调函数或者传递给事件处理器回调函数的数据对象\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象或者事件处理器回调函数的 this 上下文指向,\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向,或者是否仅触发一次\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n * @param {Boolean} once - (可选)是否仅触发一次\n */\nconst at = (el, type, fn, data, context, once = false) => {\n // CAPTURE_EVENTS 中的特殊事件,采用事件捕获模型\n const capture = CAPTURE_EVENTS.indexOf(type) > -1\n const listener = function (evt) {\n let overrideContext = context || el\n\n // 当设置为 true 时,则事件处理器回调函数的\n // this 上下文指向为 data 对象\n if (context === true) {\n overrideContext = data\n }\n\n // 仅触发一次\n /* istanbul ignore else */\n if (once === true) {\n off(el, type, listener)\n }\n\n fn.call(overrideContext, evt, data)\n }\n\n if (!isFunction(fn)) {\n return false\n }\n\n if (!el._listeners) {\n el._listeners = []\n }\n\n // 缓存 options 元素绑定的事件处理器\n el._listeners.push({\n el,\n type,\n fn: listener,\n data,\n context,\n capture\n })\n\n // 缓存包装后的事件处理器\n fn._delegateListener = listener\n\n el.addEventListener(type, listener, capture)\n}\n\nexport default at\n","/**\n * 获取 options 节点下匹配 selector 选择器的 DOM 节点\n * ========================================================================\n * Element.matches() 方法可以用来判断 DOM 元素是否与给定的选择器匹配,事件代理判断是\n * 否触发绑定的代理事件回调函数,关键就是使用 Element.matches() 辨别当前事件触发的目\n * 标 DOM 元素是否为事件代理所期望触发的目标。\n * ========================================================================\n * @method matches\n * @see https://developer.mozilla.org/en-US/docs/web/api/element/matches\n * @param {HTMLElement} el - (必须)DOM 元素\n * @param {String} selector - (必须)匹配 DOM 元素的选择器\n * @returns {Boolean}\n */\nconst matches = (el, selector = '') => {\n const sel = selector.replace(/^>/i, '')\n\n if (!selector || !sel || !el) {\n return false\n }\n\n /* istanbul ignore else */\n if (el.matches) {\n return el.matches(sel)\n } else if (el.msMatchesSelector) {\n return el.msMatchesSelector(sel)\n } else {\n return false\n }\n}\n\nexport default matches\n","/**\n * 获取 DOM 元素的父节点\n * ========================================================================\n * @method getParentOrHost\n * @param {*|HTMLElement} el - (必须)要获取父节点的 DOM 元素\n * @returns {*|HTMLElement}\n */\nconst getParentOrHost = (el) => {\n return el.host && el !== document && el.host.nodeType\n ? el.host\n : el.parentNode\n}\n\nexport default getParentOrHost\n","/**\n * 在某些情况下,某些浏览器(例如:Safari 浏览器)会返回实际的目标元素内部的文本节点。\n * resolveTextNode() 方法则会返回实际的目标节点。\n * ========================================================================\n * @method resolveTextNode\n * @param {HTMLElement|Text} el - 要解析的节点\n * @return {*|HTMLElement} - 实际的目标 DOM 节点\n */\nconst resolveTextNode = function (el) {\n if (el && el.nodeType === 3) {\n return el.parentNode\n }\n\n return el\n}\n\nexport default resolveTextNode\n","import resolveTextNode from './resolveTextNode'\n\n/**\n * 返回触发事件的 target DOM 元素\n * ========================================================================\n * @method getTarget\n * @param {Event} evt - Event 对象\n * @return {HTMLElement} - Event 对象的 target DOM 元素\n */\nconst getTarget = function (evt) {\n const target = evt.target\n\n return resolveTextNode(target)\n}\n\nexport default getTarget\n","import closest from './closest'\nimport off from './off'\nimport getTarget from './getTarget'\nimport { CAPTURE_EVENTS } from './enum'\n\n/**\n * 绑定代理事件\n * ========================================================================\n * @method on\n * @param {HTMLElement|String} el - (必须)绑定代理事件的 DOM 节点\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {String} type - (必须)事件类型\n * @param {Function} fn - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向,\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n * @param {Boolean} once - (可选)是否仅触发一次\n */\nconst on = (el, selector, type, fn, data, context, once = false) => {\n // CAPTURE_EVENTS 中的特殊事件,采用事件捕获模型\n const capture = CAPTURE_EVENTS.indexOf(type) > -1\n\n const listener = function (evt) {\n const target = getTarget(evt)\n // 通过 Element.matches 方法获得点击的目标元素\n const delegateTarget = closest(target, selector, el)\n let overrideContext = context || el\n\n evt.delegateTarget = delegateTarget\n\n // 当设置为 true 时,则事件处理器回调函数的\n // this 上下文指向为 data 对象\n if (context === true) {\n overrideContext = data\n }\n\n /* istanbul ignore else */\n if (delegateTarget) {\n // 仅触发一次\n /* istanbul ignore else */\n if (once === true) {\n off(el, type, listener)\n }\n\n fn.call(overrideContext, evt, data)\n }\n }\n\n if (!el._listeners) {\n el._listeners = []\n }\n\n // 缓存 options 元素绑定的事件处理器\n el._listeners.push({\n el,\n selector,\n type,\n fn: listener,\n data,\n context,\n capture\n })\n\n // 缓存包装后的事件处理器\n fn._delegateListener = listener\n\n el.addEventListener(type, listener, capture)\n}\n\nexport default on\n","import matches from './matches'\nimport getParentOrHost from './getParentOrHost'\n\n/**\n * 获取 options 元素父元素最近的包含 selector 选择器的元素\n * ========================================================================\n * @method closest\n * @param {HTMLElement} el - (必须)DOM 元素\n * @param {String} selector - (必须)DOM 元素的选择其\n * @param {HTMLElement} [ctx] - (必须)比对的 DOM 元素\n * @param {Boolean} [includeCTX] - (必须)是否包含 context DOM 元素\n * @returns {null|HTMLElement} - 返回最接近的 DOM 元素\n */\nconst closest = (el, selector, ctx, includeCTX) => {\n const context = ctx || document\n\n if (!el) {\n return null\n }\n\n do {\n /* istanbul ignore else */\n if (\n (selector != null &&\n (selector[0] === '>'\n ? el.parentNode === context && matches(el, selector)\n : matches(el, selector))) ||\n (includeCTX && el === context)\n ) {\n return el\n }\n\n /* istanbul ignore else */\n if (el === context) {\n break\n }\n\n /* jshint boss:true */\n } while ((el = getParentOrHost(el)))\n}\n\nexport default closest\n","/**\n * 检测当前浏览器是否为 IE 浏览器\n * ========================================================================\n * IE 浏览器返回 true,其它浏览器返回 false\n * ========================================================================\n * @method isIE\n * @returns {Boolean} - IE 浏览器返回 true,其它浏览器返回 false\n */\nconst isIE = () => {\n const agent = navigator.userAgent\n\n return !!agent.match(/Trident/g) || !!agent.match(/MSIE/g)\n}\n\nexport default isIE\n","import getListeners from './getListeners'\n\n/**\n * 返回已绑定的事件类型的数组(去除名称重复的事件)\n * ========================================================================\n * @method getTypes\n * @returns {Array}\n */\nconst getTypes = (el) => {\n const listeners = getListeners(el)\n const types = []\n\n listeners.forEach((listener) => {\n types.push(listener.type)\n })\n\n return [...new Set(types)]\n}\n\nexport default getTypes\n","/**\n * 获取 scrollTop 和 scrollLeft 数组数据\n * ========================================================================\n * IE 浏览器种计算 pageX 和 pageY,需要包含 scrollTop 和 scrollLeft 的值\n * ========================================================================\n * @method getScroll\n * @return {Array} - 返回滚动信息的数组 [scrollTop, scrollLeft]\n */\nconst getScroll = function () {\n const $body = document.documentElement || document.body\n let scrollXY = [0, 0]\n\n if ($body && ($body.scrollTop || $body.scrollLeft)) {\n scrollXY = [$body.scrollTop, $body.scrollLeft]\n }\n\n return scrollXY\n}\n\nexport default getScroll\n","import getScrollLeft from './getScrollLeft'\nimport isIE from './utils/isIE'\n\n/**\n * 获取事件触发时的 pageX 值\n * ========================================================================\n * @method getPageX\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageX\n * @param {Event} evt - (必须)Event 对象\n * @return {Number} - 返回事件触发时的 pageX 值\n */\nconst getPageX = function (evt) {\n let x = evt.pageX\n\n /* istanbul ignore else */\n if (!x && 0 !== x) {\n x = evt.clientX || 0\n\n if (isIE()) {\n x += getScrollLeft()\n }\n }\n\n return x\n}\n\nexport default getPageX\n","import getScroll from './getScroll'\n\n/**\n * 获取 scrollTop 值\n * ========================================================================\n * @method getScrollLeft\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollLeft\n * @return {Number} - 返回 scrollLeft 值\n */\nconst getScrollLeft = function () {\n return getScroll()[1]\n}\n\nexport default getScrollLeft\n","import getScrollTop from './getScrollTop'\nimport isIE from './utils/isIE'\n\n/**\n * 获取事件触发时的 pageY 值\n * ========================================================================\n * @method getPageY\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/pageY\n * @param {Event} evt - (必须)Event 对象\n * @return {Number} - 返回事件触发时的 pageY 值\n */\nconst getPageY = function (evt) {\n let y = evt.pageY\n\n /* istanbul ignore else */\n if (!y && 0 !== y) {\n y = evt.clientY || 0\n\n if (isIE()) {\n y += getScrollTop()\n }\n }\n\n return y\n}\n\nexport default getPageY\n","import getScroll from './getScroll'\n\n/**\n * 获取 scrollTop 值\n * ========================================================================\n * @method getScrollTop\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollTop\n * @return {Number} - 返回 getScrollTop 值\n */\nconst getScrollTop = function () {\n return getScroll()[0]\n}\n\nexport default getScrollTop\n","import isAppleSafari from './utils/isAppleSafari'\n\n/**\n * 返回触发事件的 charCode\n * ========================================================================\n * @method getCharCode\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/KeyboardEvent/keyCode\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/KeyboardEvent/charCode\n * @param {Event} evt - Event 对象\n * @return {Number} - 返回事件的 charCode\n */\nconst getCharCode = function (evt) {\n let code = evt.keyCode || evt.charCode\n // keycodes for webkit/safari\n const webkitKeymap = {\n 63232: 38, // up\n 63233: 40, // down\n 63234: 37, // left\n 63235: 39, // right\n 63276: 33, // page up\n 63277: 34, // page down\n 25: 9 // The SHIFT-TAB (Safari provides a different key code in\n // this case, even though the shiftKey modifier is set)\n }\n\n // webkit key normalization\n if (isAppleSafari() && code in webkitKeymap) {\n code = webkitKeymap[code]\n }\n\n return code\n}\n\nexport default getCharCode\n","/**\n * 判断是否为 Apple 设备的 Safari 浏览器\n * ========================================================================\n * @method isAppleSafari\n * @returns {Boolean}\n */\nconst isAppleSafari = () => {\n const UA = navigator.userAgent\n const platforms = /Mac|iPhone|iPod|iPad/i\n const rejected = /Chrome|Android|CriOS|FxiOS|EdgiOS/i\n const expected = /Safari/i\n\n if (rejected.test(UA)) {\n return false\n }\n\n return platforms.test(UA) && expected.test(UA)\n}\n\nexport default isAppleSafari\n","/**\n * 阻止触发绑定事件 DOM 元素的默认行为\n * ========================================================================\n * @method preventDefault\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault\n * @param {Event} evt - 事件对象\n *\n * @example\n * <div id=\"nav\" class=\"nav\">\n * <a id=\"service\" class=\"anchor\" href=\"https://www.yaohaixiao.com/serivce\">Service</a>\n * <a id=\"help\" class=\"anchor\" href=\"https://www.yaohaixiao.com/help\">Help</a>\n * </div>\n *\n * const $nav = document.querySelector('#nav')\n * const $service = document.querySelector('.anchor')\n *\n * on($nav, 'click', function(evt) {\n * console.log('你点击了导航栏')\n * })\n *\n * on($anchor, 'click', function(evt) {\n * console.log('tagName', this.tagName)\n *\n * // 在工作台输出:'a'\n * // 会触发事件冒泡,输出:'你点击了导航栏'\n * // 但不会切换到 href 属性的页面地址,阻止了点击链接的默认行为\n * stopEvent(evt)\n * })\n */\nconst preventDefault = function (evt) {\n evt.preventDefault()\n}\n\nexport default preventDefault\n","/**\n * 终止事件在传播过程的捕获或冒泡的事件流\n * ========================================================================\n * @method stopPropagation\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopPropagation\n * @param {Event} evt - 事件对象\n *\n * @example\n * <div id=\"nav\" class=\"nav\">\n * <a id=\"service\" class=\"anchor\" href=\"https://www.yaohaixiao.com/serivce\">Service</a>\n * <a id=\"help\" class=\"anchor\" href=\"https://www.yaohaixiao.com/help\">Help</a>\n * </div>\n *\n * const $nav = document.querySelector('#nav')\n * const $service = document.querySelector('.anchor')\n *\n * on($nav, 'click', function(evt) {\n * console.log('你点击了导航栏')\n * })\n *\n * on($anchor, 'click', function(evt) {\n * console.log('tagName', this.tagName)\n *\n * // 工作台输出:'a'\n * // 然后跳转到 href 的地址\n * // 但不会触发事件冒泡,输出:'你点击了导航栏'\n * stopPropagation(evt)\n * })\n */\nconst stopPropagation = function (evt) {\n evt.stopPropagation()\n}\n\nexport default stopPropagation\n","import stopPropagation from './stopPropagation'\nimport preventDefault from './preventDefault'\n\n/**\n * 停止事件(阻止默认行为和阻止事件的捕获或冒泡)\n * ========================================================================\n * @method stopEvent\n * @param {Event} evt - 事件对象\n *\n * @example\n * <div id=\"nav\" class=\"nav\">\n * <a id=\"service\" class=\"anchor\" href=\"https://www.yaohaixiao.com/serivce\">Service</a>\n * <a id=\"help\" class=\"anchor\" href=\"https://www.yaohaixiao.com/help\">Help</a>\n * </div>\n *\n * const $nav = document.querySelector('#nav')\n * const $service = document.querySelector('.anchor')\n *\n * on($nav, 'click', function(evt) {\n * console.log('你点击了导航栏')\n * })\n *\n * on($anchor, 'click', function(evt) {\n * console.log('tagName', this.tagName)\n *\n * // 工作台输出:'a'\n * // 不会触发事件冒泡,输出:'你点击了导航栏'\n * // 也不会切换到 href 属性的页面,阻止了点击链接的默认行为\n * stopEvent(evt)\n * })\n */\nconst stopEvent = function (evt) {\n stopPropagation(evt)\n preventDefault(evt)\n}\n\nexport default stopEvent\n","import createEvent from './createEvent'\nimport off from './off'\nimport at from './at'\nimport on from './on'\nimport only from './only'\nimport once from './once'\nimport focusin from './focusin'\nimport focusout from './focusout'\nimport isElement from './utils/isElement'\nimport isString from './utils/isString'\nimport getListeners from './getListeners'\nimport getTypes from './getTypes'\nimport hasEvent from './hasEvent'\nimport getPageX from './getPageX'\nimport getPageY from './getPageY'\nimport getPageXY from './getPageXY'\nimport getCharCode from './getCharCode'\nimport getRelatedTarget from './getRelatedTarget'\nimport getTarget from './getTarget'\nimport purgeElement from './purgeElement'\nimport destroy from './destroy'\nimport preventDefault from './preventDefault'\nimport stopPropagation from './stopPropagation'\nimport stopEvent from './stopEvent'\nimport stopImmediate from './stopImmediate'\nimport trigger from './trigger'\n\n/**\n * Emitter 类 - JavaScript 事件代理对象\n * ========================================================================\n */\nclass Emitter {\n /**\n * Emitter 构造函数\n * ========================================================================\n * @constructor\n * @param {HTMLElement|String} el - (必须)DOM 元素或其选择器\n * @returns {Emitter} - Emitter 对象\n */\n constructor(el) {\n if (isElement(el)) {\n this.$el = el\n } else {\n if (isString(el)) {\n this.$el = document.querySelector(el)\n }\n }\n }\n\n /**\n * 获取 DOM 元素(type 事件类型)事件绑定信息\n * ========================================================================\n * 如果设置了事件类型 type, 则返回指定类型的事件绑定信息,否则返回所有事件绑定信息\n * ========================================================================\n * @method getListeners\n * @param {String} [type] - (可选)事件类型\n * @returns {Array} - 已绑定的事件信息\n */\n getListeners(type) {\n return getListeners(this.$el, type)\n }\n\n /**\n * 返回已绑定的事件类型的数组(去除名称重复的事件)\n * ========================================================================\n * @method getTypes\n * @since 1.5.0\n * @returns {Array}\n */\n getTypes() {\n return getTypes(this.$el)\n }\n\n /**\n * 判断是否已经(指定类型的)绑定事件\n * ========================================================================\n * @method hasEvent\n * @since 1.4.0\n * @param {String} [type] - (可选)事件名称:\n * 指定 type,则判断是否绑定 type 类型事件;\n * 未指定 type,则判断是否绑定任意类型的事件;\n * @returns {Boolean}\n */\n hasEvent(type) {\n return hasEvent(this.$el, type)\n }\n\n /**\n * 获取事件触发时的 pageX 值\n * ========================================================================\n * @method getPageX\n * @see getPageX\n * @param {Event} evt - (必须)Event 对象\n * @return {Number} - 返回事件触发时的 pageX 值\n */\n getPageX(evt) {\n return getPageX(evt)\n }\n\n /**\n * 获取事件触发时的 pageY 值\n * ========================================================================\n * @method getPageY\n * @see getPageY\n * @param {Event} evt - (必须)Event 对象\n * @return {Number} - 返回事件触发时的 pageY 值\n */\n getPageY(evt) {\n return getPageY(evt)\n }\n\n /**\n * 获取事件触发时的 pageX 和 pageY 数组数据\n * ========================================================================\n * @method getPageXY\n * @see getPageXY\n * @param {Event} evt - (必须)Event 对象\n * @return {Array} - 返回事件触发时的数组数据:[pageX, pageY]\n */\n getPageXY(evt) {\n return getPageXY(evt)\n }\n\n /**\n * 返回触发事件的 charCode\n * ========================================================================\n * @method getCharCode\n * @see getCharCode\n * @param {Event} evt - (必须)Event 对象\n * @return {Number} - 返回事件的 charCode\n */\n getCharCode(evt) {\n return getCharCode(evt)\n }\n\n /**\n * 返回触发(鼠标)事件的 relatedTarget DOM 元素。\n * ========================================================================\n * MouseEvent.relatedTarget 只读属性是鼠标事件的次要目标(如果有)。相关的鼠标事件:\n * mouseenter\n * mouseleave\n * mouseover\n * mouseout\n * dragenter\n * dragleave\n * ========================================================================\n * @method getRelatedTarget\n * @since 1.1.0\n * @see https://developer.mozilla.org/en-US/docs/web/api/mouseevent/relatedtarget\n * @param {Event} evt - Event 对象\n * @return {HTMLElement} - Event 对象的 relatedTarget DOM 元素\n */\n getRelatedTarget(evt) {\n return getRelatedTarget(evt)\n }\n\n /**\n * 返回触发事件的 target DOM 元素\n * ========================================================================\n * @method getTarget\n * @since 1.1.0\n * @param {Event} evt - Event 对象\n * @return {HTMLElement} - Event 对象的 target DOM 元素\n */\n getTarget(evt) {\n return getTarget(evt)\n }\n\n /**\n * 销毁(type 类型的)代理事件绑定\n * ========================================================================\n * 1. 设置了事件类型 type,则销毁指定类型的事件绑定,否则清除所有代理事件绑定\n * 2. recurse 设置为 true,递归销毁子节点全部事件绑定\n * ========================================================================\n * @method purge\n * @param {String} type - (必须)事件类型\n * @param {Boolean} [recurse] - (可选)是否递归销毁子节点所有事件绑定\n * 元素绑定的全部事件处理器\n * @returns {Emitter} - Emitter 对象\n */\n purge(type, recurse = false) {\n purgeElement(this.$el, type, recurse)\n\n return this\n }\n\n /**\n * 销毁所有已绑定的代理事件\n * ========================================================================\n * @method destroy\n * @returns {Emitter} - Emitter 对象\n */\n destroy() {\n destroy(this.$el)\n\n return this\n }\n\n /**\n * 创建自定义事件(CustomerEvent)\n * ========================================================================\n * @method createEvent\n * @since 1.8.0\n * @see createEvent\n * @param {String} type - (必须)事件类型(名称)\n * @param {Object} [detail] - (可选)传递给自定义事件的数据,默认为 null\n * @param {Boolean} [bubbles] - (可选)是否支持冒泡,默认为 true\n * @param {Boolean} [cancelable] - (可选)是否可以取消,默认为 true\n * @returns {CustomEvent} - CustomerEvent 实例\n */\n createEvent(type, detail = null, bubbles = true, cancelable = true) {\n return createEvent(type, detail, bubbles, cancelable)\n }\n\n /**\n * 取消 type 类型的代理事件绑定\n * ========================================================================\n * 如果没有设置 handler,则销毁 this.$options 绑定的所有符合 type 事件类型的事件绑定\n * ========================================================================\n * @method off\n * @param {String} type - (必须)事件类型\n * @param {Function} [handler] - (可选)事件处理器回调函数\n * @returns {Emitter} - Emitter 对象\n */\n off(type, handler) {\n off(this.$el, type, handler)\n\n return this\n }\n\n /**\n * 绑定事件\n * ========================================================================\n * @method at\n * @param {String|Function} type - (必须)事件类型或者事件处理器回调函数\n * @param {Function|Object} fn - (必须) 事件处理器回调函数或者传递给事件处理器回调函数的数据对象\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象或者事件处理器回调函数的 this 上下文指向,\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向,或者是否仅触发一次\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n * @param {Boolean} once - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n at(type, fn, data, context, once = false) {\n at(this.$el, type, fn, data, context, once)\n\n return this\n }\n\n /**\n * 绑定代理事件\n * ========================================================================\n * @method on\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {String} type - (必须)事件类型\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向:\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象;\n * 如未指定 context,则事件处理器回调函数的 this 上下文指向为 Emitter 对象;\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n on(selector, type, handler, data, context, once = false) {\n on(this.$el, selector, type, handler, data, context || this, once)\n\n return this\n }\n\n /**\n * 绑定仅触发一次的事件\n * ========================================================================\n * @method only\n * @param {String} type - (必须)事件类型\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @returns {Emitter} - Emitter 对象\n */\n only(type, handler, data, context) {\n only(this.$el, type, handler, data, context)\n\n return this\n }\n\n /**\n * 绑定仅触发一次的代理事件\n * ========================================================================\n * @method once\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {String} type - (必须)事件类型\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @returns {Emitter} - Emitter 对象\n */\n once(selector, type, handler, data, context) {\n once(this.$el, selector, type, handler, data, context)\n\n return this\n }\n\n /**\n * 绑定 click 代理事件\n * ========================================================================\n * @method click\n * @since 1.4.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/click_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n click(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'click', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dbclick 代理事件\n * ========================================================================\n * @method dbclick\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/dblclick_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dbclick(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dbclick', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mouseenter 代理事件\n * ========================================================================\n * @method mouseenter\n * @since 1.4.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mouseenter(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mouseenter', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mouseleave 代理事件\n * ========================================================================\n * @method mouseleave\n * @since 1.4.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mouseleave(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mouseleave', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mousedown 代理事件\n * ========================================================================\n * @method mousedown\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mousedown_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mousedown(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mousedown', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mouseup 代理事件\n * ========================================================================\n * @method mouseup\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseup_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mouseup(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mouseup', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mouseover 代理事件\n * ========================================================================\n * @method mouseover\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mouseover(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mouseover', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mousemove 代理事件\n * ========================================================================\n * @method mousemove\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mousemove(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mousemove', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 mouseout 代理事件\n * ========================================================================\n * @method mouseout\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseout_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n mouseout(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'mouseout', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 drag 代理事件\n * ========================================================================\n * @method drag\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/drag_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n drag(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'drag', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dragend 代理事件\n * ========================================================================\n * @method dragend\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/dragend_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dragend(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dragend', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dragenter 代理事件\n * ========================================================================\n * @method dragenter\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/dragenter_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dragenter(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dragenter', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dragleave 代理事件\n * ========================================================================\n * @method dragleave\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/dragleave_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dragleave(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dragleave', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dragover 代理事件\n * ========================================================================\n * @method dragover\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/dragover_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dragover(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dragover', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 dragstart 代理事件\n * ========================================================================\n * @method dragstart\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/dragstart_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n dragstart(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'dragstart', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 drop 代理事件\n * ========================================================================\n * @method drop\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/drop_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n drop(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'drop', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 wheel 代理事件\n * ========================================================================\n * @method wheel\n * @since 1.7.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n wheel(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'wheel', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 contextmenu 代理事件\n * ========================================================================\n * @method contextmenu\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/contextmenu_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n contextmenu(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'contextmenu', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 focusin 或者 focus 代理事件\n * ========================================================================\n * @method focusin\n * @since 1.4.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/focus_event\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n focusin(selector, handler, data, context, once = false) {\n focusin(this.$el, selector, handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 focusout 或者 blur 代理事件\n * ========================================================================\n * @method focusout\n * @since 1.4.0\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n focusout(selector, handler, data, context, once = false) {\n focusout(this.$el, selector, handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 change 代理事件\n * ========================================================================\n * @method change\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/change_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n change(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'change', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 input 代理事件\n * ========================================================================\n * @method input\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/input_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n input(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'input', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 compositionstart 代理事件\n * ========================================================================\n * @method compositionstart\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/compositionstart_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n compositionstart(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'compositionstart', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 compositionupdate 代理事件\n * ========================================================================\n * @method compositionupdate\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/compositionupdate_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n compositionupdate(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'compositionupdate', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 compositionend 代理事件\n * ========================================================================\n * @method compositionend\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/compositionend_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n compositionend(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'compositionend', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 paste 代理事件\n * ========================================================================\n * @method paste\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/paste_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n paste(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'paste', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 copy 代理事件\n * ========================================================================\n * @method copy\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/copy_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n copy(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'copy', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 cut 代理事件\n * ========================================================================\n * @method cut\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/cut_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n cut(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'cut', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 keydown 代理事件\n * ========================================================================\n * @method keydown\n * @since 1.7.0\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n keydown(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'keydown', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 keyup 代理事件\n * ========================================================================\n * @method keyup\n * @since 1.7.0\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n keyup(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'keyup', handler, data, context, once)\n\n return this\n }\n\n /**\n * 绑定 error 代理事件\n * ========================================================================\n * @method error\n * @since 1.7.0\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/error_event\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} handler - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向\n * @param {Boolean} [once] - (可选)是否仅触发一次\n * @returns {Emitter} - Emitter 对象\n */\n error(selector, handler, data, context, once = false) {\n on(this.$el, selector, 'error', handler, data, context, once)\n\n return this\n }\n\n /**\n * 触发代理自定义事件\n * ========================================================================\n * @method trigger\n * @since 1.6.0\n * @param {String} type - (必须)事件类型\n * @param {String} selector - (必须)选择器\n * @returns {Emitter} - Emitter 对象\n */\n trigger(type, selector) {\n trigger(this.$el, type, selector)\n\n return this\n }\n\n /**\n * 阻止事件的默认行为\n * ========================================================================\n * @method preventDefault\n * @see preventDefault\n * @param {Event} evt - (必须)Event 对象\n * @returns {Emitter} - Emitter 对象\n */\n preventDefault(evt) {\n preventDefault(evt)\n\n return this\n }\n\n /**\n * 终止事件在传播过程的捕获或冒泡的事件流\n * ========================================================================\n * @method stopPropagation\n * @see stopPropagation\n * @param {Event} evt - (必须)Event 对象\n * @returns {Emitter} - Emitter 对象\n */\n stopPropagation(evt) {\n stopPropagation(evt)\n\n return this\n }\n\n /**\n * 停止事件(阻止默认行为和阻止事件的捕获或冒泡)\n * ========================================================================\n * @method stopEvent\n * @see stopEvent\n * @param {Event} evt - (必须)Event 对象\n * @returns {Emitter} - Emitter 对象\n */\n stopEvent(evt) {\n stopEvent(evt)\n\n return this\n }\n\n /**\n * 阻止监听同一事件的其他事件监听器被调用,并且阻止默认行为和事件冒泡。\n * ========================================================================\n * @method stopImmediate\n * @since 1.8.0\n * @see stopImmediate\n * @param {Event} evt - (必须)Event 对象\n */\n stopImmediate(evt) {\n stopImmediate(evt)\n\n return this\n }\n}\n\nexport default Emitter\n","import isString from './utils/isString'\nimport getTypes from './getTypes'\n\n/**\n * 判断是否已经(指定类型的)绑定事件\n * ========================================================================\n * @method hasEvent\n * @param {HTMLElement} el - 要检测是否绑定事件的 DOM 元素\n * @param {String} [type] - (可选)事件名称:\n * 指定 type,则判断是否绑定 type 类型事件;\n * 未指定 type,则判断是否绑定任意类型的事件;\n * @returns {Boolean}\n */\nconst hasEvent = (el, type) => {\n const types = getTypes(el)\n let result\n\n if (types.length < 1) {\n return false\n }\n\n result = types.length > 0\n\n /* istanbul ignore else */\n if (type && isString(type)) {\n result = types.indexOf(type) > -1\n }\n\n return result\n}\n\nexport default hasEvent\n","import getPageX from './getPageX'\nimport getPageY from './getPageY'\n\n/**\n * 获取事件触发时的 pageX 和 pageY 数组数据\n * ========================================================================\n * @method getPageXY\n * @param {Event} evt - (必须)Event 对象\n * @return {Array} - 返回事件触发时的数组数据:[pageX, pageY]\n */\nconst getPageXY = function (evt) {\n return [getPageX(evt), getPageY(evt)]\n}\n\nexport default getPageXY\n","import resolveTextNode from './resolveTextNode'\n\n/**\n * 返回触发(鼠标)事件的 relatedTarget DOM 元素。\n * ========================================================================\n * MouseEvent.relatedTarget 只读属性是鼠标事件的次要目标(如果有)。相关的鼠标事件:\n * mouseenter\n * mouseleave\n * mouseover\n * mouseout\n * dragenter\n * dragleave\n * ========================================================================\n * @method getRelatedTarget\n * @see https://developer.mozilla.org/en-US/docs/web/api/mouseevent/relatedtarget\n * @param {Event} evt - Event 对象\n * @return {HTMLElement} - Event 对象的 relatedTarget DOM 元素\n */\nconst getRelatedTarget = function (evt) {\n let target = evt.relatedTarget\n const type = evt.type\n\n if (!target) {\n if (type === 'mouseout') {\n target = evt.toElement\n } else if (type === 'mouseover') {\n target = evt.fromElement\n }\n }\n\n return resolveTextNode(target)\n}\n\nexport default getRelatedTarget\n","import getTypes from './getTypes'\nimport purgeElement from './purgeElement'\n\n/**\n * 销毁所有已绑定的代理事件\n * ========================================================================\n * @method destroy\n * @param {HTMLElement} el - 需要解除所有事件绑定的 DOM 元素\n * @returns {Emitter} - Emitter 对象\n */\nconst destroy = (el) => {\n const types = getTypes(el)\n\n types.forEach((type) => {\n purgeElement(el, type, true)\n })\n}\n\nexport default destroy\n","import at from './at'\n\n/**\n * 绑定只触发一次的事件\n * ========================================================================\n * @method once\n * @param {HTMLElement} el - (必须)绑定代理事件的 DOM 节点\n * @param {String} type - (必须)事件类型\n * @param {Function} fn - (必须) 事件处理器回调函数\n * @param {Object} data - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} context - (可选)事件处理器回调函数的 this 上下文指向,\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n */\nconst only = (el, type, fn, data, context) => {\n at(el, type, fn, data, context, true)\n}\n\nexport default only\n","import on from './on'\n\n/**\n * 绑定只触发一次的事件\n * ========================================================================\n * @method once\n * @param {HTMLElement} el - (必须)绑定代理事件的 DOM 节点\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {String} type - (必须)事件类型\n * @param {Function} fn - (必须) 事件处理器回调函数\n * @param {Object} data - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} context - (可选)事件处理器回调函数的 this 上下文指向,\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n */\nconst once = (el, selector, type, fn, data, context) => {\n on(el, selector, type, fn, data, context, true)\n}\n\nexport default once\n","import isIE from './utils/isIE'\nimport on from './on'\n\n/**\n * 绑定 focusin 或者 focus 代理事件\n * ========================================================================\n * @method focusin\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/focus_event\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event\n * @param {HTMLElement} el - (必须)绑定代理事件的 DOM 节点\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} fn - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向,\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n * @param {Boolean} [once] - (可选)是否仅触发一次\n */\nconst focusin = function (el, selector, fn, data, context, once = false) {\n const FOCUSIN = isIE() ? 'focusin' : 'focus'\n\n return on(el, selector, FOCUSIN, fn, data, context, once)\n}\n\nexport default focusin\n","import isIE from './utils/isIE'\nimport on from './on'\n\n/**\n * 绑定 focusout 或者 blur 代理事件\n * ========================================================================\n * @method focusout\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event\n * @param {HTMLElement} el - (必须)绑定代理事件的 DOM 节点\n * @param {String} selector - (必须)事件代理目标 DOM 元素的选择器\n * @param {Function} fn - (必须) 事件处理器回调函数\n * @param {Object} [data] - (可选)传递给事件处理器回调函数的数据对象\n * @param {Object|Boolean} [context] - (可选)事件处理器回调函数的 this 上下文指向,\n * 当设置为 true 时,则事件处理器回调函数的 this 上下文指向为 data 对象\n * @param {Boolean} [once] - (可选)是否仅触发一次\n */\nconst focusout = function (el, selector, fn, data, context, once = false) {\n const FOCUSOUT = isIE() ? 'focusout' : 'blur'\n\n on(el, selector, FOCUSOUT, fn, data, context, once)\n}\n\nexport default focusout\n","import createEvent from './createEvent'\n\n/**\n * 触发代理自定义事件\n * ========================================================================\n * trigger() 方法也可以用来手动触发内置的事件,例如 click, mouseenter 等事件,通常\n * 使用 trigger() 来手动触发用户自定义事件。\n *\n * 另外,选择器 selector 的匹配使用 document.querySelector() 方法,因此仅事件触发一次。\n * ========================================================================\n * @method trigger\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/CustomEvent\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/dispatchEvent\n * @param {HTMLElement} el - (必须)绑定代理事件的 DOM 元素\n * @param {String} type - (必须)事件类型\n * @param {String} [selector] - (可选)选择器,没有选择器,则直接触发 el 元素上的自定义事件\n *\n * @example\n * const $list = document.querySelector('#list')\n *\n * // 绑定 alert 自定义事件\n * on($list, '.item', 'alert', itemHandler)\n * on($list, '.remove', 'alert', removeHandler)\n *\n * // 触发 $list 下匹配 '.item' 元素手动触发 alert 自定义事件\n * trigger($list, 'alert', '.item')\n *\n * // 可以使用伪类选择器,更精确的匹配元素\n * trigger($list, 'alert', '.item:last-child')\n *\n * // 触发 $list 下匹配 '.remove' 元素手动触发 alert 自定义事件\n * trigger($list, 'alert', '.remove')\n * trigger($list, 'alert', '.remove:nth-child(2)')\n *\n * // 没有选择器,则直接触发 el 元素上的自定义事件\n * trigger($list, 'alert')\n */\nconst trigger = (el, type, selector) => {\n let $element\n\n if (!type) {\n return false\n }\n\n if (selector) {\n $element = el.querySelector(selector)\n } else {\n $element = el\n }\n\n if (!$element) {\n return false\n }\n\n $element.dispatchEvent(createEvent(type))\n}\n\nexport default trigger\n","import stopEvent from './stopEvent'\n\n/**\n * 阻止监听同一事件的其他事件监听器被调用,并且阻止默认行为和事件冒泡。\n * ========================================================================\n * @method stopImmediate\n * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Event/stopImmediatePropagation\n * @param {Event} evt - (必须)Event 对象\n *\n * @example\n * <div id=\"nav\" class=\"nav\">\n * <a id=\"service\" class=\"anchor\" href=\"https://www.yaohaixiao.com/serivce\">Service</a>\n * <a id=\"help\" class=\"anchor\" href=\"https://www.yaohaixiao.com/help\">Help</a>\n * </div>\n *\n * const $nav = document.querySelector('#nav')\n * const $service = document.querySelector('#service')\n * const logHandler = function(evt) {\n * console.log(evt.target)\n * }\n * const styleHandler = function(evt) {\n * $nav.classList.add('checked')\n * }\n * const serviceHandler = function(evt) {\n * alert(evt.target)\n * stopImmediate(evt)\n * }\n * const removeHandler = function(evt) {\n * const $target = evt.target\n *\n * $target.parentNode.removeChild($target)\n * }\n *\n * $nav.addEventListener('click', logHandler)\n * $nav.addEventListener('click', styleHandler)\n * $service.addEventListener('click', serviceHandler)\n * $service.addEventListener('click', removeHandler)\n *\n * $nav.click()\n * // => 触发 logHandler 和 styleHandler\n *\n * $service.click()\n * // => 仅触发 serviceHandler,不会触发 removeHandler\n * // => 并且不会跳转页面,也不会冒泡到 $nav,不会触发 logHandler 和 styleHandler\n */\nconst stopImmediate = function (evt) {\n stopEvent(evt)\n evt.stopImmediatePropagation()\n}\n\nexport default stopImmediate\n","import Emitter from './emitter'\n\nconst delegate = (el) => {\n return new Emitter(el)\n}\n\nexport default delegate\n"],"names":["createEvent","type","detail","bubbles","cancelable","CustomEvent","isString","val","isElement","el","nodeName","tagName","nodeType","getListeners","listeners","_listeners","filter","listener","CAPTURE_EVENTS","_off","fn","capture","indexOf","_delegateListener","index","length","forEach","i","handler","splice","_delete","removeEventListener","purgeElement","recurse","$element","document","querySelector","$children","childNodes","arguments","$child","isFunction","Object","prototype","toString","apply","_typeof","off","at","data","context","once","evt","overrideContext","call","push","addEventListener","matches","selector","sel","replace","msMatchesSelector","getParentOrHost","host","parentNode","resolveTextNode","getTarget","target","on","delegateTarget","ctx","includeCTX","closest","isIE","agent","navigator","userAgent","match","getTypes","types","Set","getScroll","$body","documentElement","body","scrollXY","scrollTop","scrollLeft","getPageX","x","pageX","clientX","getPageY","y","pageY","clientY","getCharCode","code","keyCode","charCode","webkitKeymap","UA","test","isAppleSafari","preventDefault","stopPropagation","stopEvent","Emitter","constructor","this","$el","hasEvent","result","getPageXY","getRelatedTarget","relatedTarget","toElement","fromElement","purge","destroy","only","click","dbclick","mouseenter","mouseleave","mousedown","mouseup","mouseover","mousemove","mouseout","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","wheel","contextmenu","focusin","FOCUSIN","focusout","FOCUSOUT","change","input","compositionstart","compositionupdate","compositionend","paste","copy","cut","keydown","keyup","error","trigger","dispatchEvent","stopImmediate","stopImmediatePropagation"],"mappings":"yOAiCA,MAAMA,EAAc,CAClBC,EACAC,EAAS,KACTC,GAAU,EACVC,GAAa,IAEN,IAAIC,YAAYJ,EAAM,CAC3BC,OAAQA,EACRC,QAASA,EACTC,WAAYA,ICnCVE,EAAYC,GACM,iBAARA,ECDVC,EAAaC,MACPA,GAAMA,EAAGC,UAAYD,EAAGE,SAA2B,IAAhBF,EAAGG,UCI5CC,EAAe,CAACJ,EAAIR,KACxB,IAAIa,EAAYL,EAAGM,YAAc,GAQjC,OANIT,EAASL,IAASA,IACpBa,EAAYA,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