1 line
10 KiB
JSON
1 line
10 KiB
JSON
|
{"ast":null,"code":"'use strict';\n\nrequire(\"core-js/modules/es.regexp.exec.js\");\n\nrequire(\"core-js/modules/es.regexp.test.js\");\n\nrequire(\"core-js/modules/es.array.concat.js\");\n\nrequire(\"core-js/modules/es.object.to-string.js\");\n\nrequire(\"core-js/modules/web.dom-collections.iterator.js\");\n\nexports.__esModule = true;\nvar aria = aria || {};\naria.Utils = aria.Utils || {};\n/**\n * @desc Set focus on descendant nodes until the first focusable element is\n * found.\n * @param element\n * DOM node for which to find the first focusable descendant.\n * @returns\n * true if a focusable element is found and focus is set.\n */\n\naria.Utils.focusFirstDescendant = function (element) {\n for (var i = 0; i < element.childNodes.length; i++) {\n var child = element.childNodes[i];\n\n if (aria.Utils.attemptFocus(child) || aria.Utils.focusFirstDescendant(child)) {\n return true;\n }\n }\n\n return false;\n};\n/**\n * @desc Find the last descendant node that is focusable.\n * @param element\n * DOM node for which to find the last focusable descendant.\n * @returns\n * true if a focusable element is found and focus is set.\n */\n\n\naria.Utils.focusLastDescendant = function (element) {\n for (var i = element.childNodes.length - 1; i >= 0; i--) {\n var child = element.childNodes[i];\n\n if (aria.Utils.attemptFocus(child) || aria.Utils.focusLastDescendant(child)) {\n return true;\n }\n }\n\n return false;\n};\n/**\n * @desc Set Attempt to set focus on the current node.\n * @param element\n * The node to attempt to focus on.\n * @returns\n * true if element is focused.\n */\n\n\naria.Utils.attemptFocus = function (element) {\n if (!aria.Utils.isFocusable(element)) {\n return false;\n }\n\n aria.Utils.IgnoreUtilFocusChanges = true;\n\n try {\n element.focus();\n } catch (e) {}\n\n aria.Utils.IgnoreUtilFocusChanges = false;\n return document.activeElement === element;\n};\n\naria.Utils.isFocusable = function (element) {\n if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute('tabIndex') !== null) {\n return true;\n }\n\n if (element.disabled) {\n return false;\n }\n\n switch (element.nodeName) {\n case 'A':\n return !!element.href && element.rel !== 'ignore';\n\n case 'INPUT':\n return element.type !== 'hidden' && element.type !== 'file';\n\n case 'BUTTON':\n case 'SELECT':\n case 'TEXTAREA':\n return true;\n\n default:\n return false;\n }\n};\n/**\n * 触发一个事件\n * mouseenter, mouseleave, mouseover, keyup, change, click 等\n * @param {Element} elm\n * @param {String} name\n * @param {*} opts\n */\n\n\naria.Utils.triggerEvent = function (elm, name) {\n var eventName = void 0;\n\n if (/^mouse|click/.test(name)) {\n eventName = 'MouseEvents';\n } else if (/^key/.test(name)) {\n eventName = 'KeyboardEvent';\n } else {\n eventName = 'HTMLEvents';\n }\n\n var evt = document.createEvent(eventName);\n\n for (var _len = arguments.length, opts = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n opts[_key - 2] = arguments[_key];\n }\n\n evt.initEvent.apply(evt, [name].concat(opts));\n elm.dispatchEvent ? elm.dispatchEvent(evt) : elm.fireEvent('on' + name, evt);\n return elm;\n};\n\naria.Utils.keys = {\n tab: 9,\n enter: 13,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n esc: 27\n};\nexports.default = aria.Utils;","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src/ElectronicMallVue/node_modules/element-ui/lib/utils/aria-utils.js"],"names":["exports","__esModule","aria","Utils","focusFirstDescendant","element","i","childNodes","length","child","attemptFocus","focusLastDescendant","isFocusable","IgnoreUtilFocusChanges","focus","e","document","activeElement","tabIndex","getAttribute","disabled","nodeName","href","rel","type","triggerEvent","elm","name","eventName","test","evt","createEvent","_len","arguments","opts","Array","_key","initEvent","apply","concat","dis
|