123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Util = void 0;
- const store_1 = require("./store");
- var Util;
- (function (Util) {
- Util.returnTrue = () => true;
- Util.returnFalse = () => false;
- function stopPropagationCallback(e) {
- e.stopPropagation();
- }
- Util.stopPropagationCallback = stopPropagationCallback;
- function addEventListener(elem, type, handler) {
- if (elem.addEventListener != null) {
- elem.addEventListener(type, handler);
- }
- }
- Util.addEventListener = addEventListener;
- function removeEventListener(elem, type, handler) {
- if (elem.removeEventListener != null) {
- elem.removeEventListener(type, handler);
- }
- }
- Util.removeEventListener = removeEventListener;
- })(Util = exports.Util || (exports.Util = {}));
- (function (Util) {
- const rNotHTMLWhite = /[^\x20\t\r\n\f]+/g;
- const rNamespace = /^([^.]*)(?:\.(.+)|)/;
- function splitType(types) {
- return (types || '').match(rNotHTMLWhite) || [''];
- }
- Util.splitType = splitType;
- function normalizeType(type) {
- const parts = rNamespace.exec(type) || [];
- return {
- originType: parts[1] ? parts[1].trim() : parts[1],
- namespaces: parts[2]
- ? parts[2]
- .split('.')
- .map((ns) => ns.trim())
- .sort()
- : [],
- };
- }
- Util.normalizeType = normalizeType;
- function isValidTarget(target) {
- // Accepts only:
- // - Node
- // - Node.ELEMENT_NODE
- // - Node.DOCUMENT_NODE
- // - Object
- // - Any
- return target.nodeType === 1 || target.nodeType === 9 || !+target.nodeType;
- }
- Util.isValidTarget = isValidTarget;
- function isValidSelector(elem, selector) {
- if (selector) {
- const node = elem;
- return node.querySelector != null && node.querySelector(selector) != null;
- }
- return true;
- }
- Util.isValidSelector = isValidSelector;
- })(Util = exports.Util || (exports.Util = {}));
- (function (Util) {
- let seed = 0;
- const cache = new WeakMap();
- function ensureHandlerId(handler) {
- if (!cache.has(handler)) {
- cache.set(handler, seed);
- seed += 1;
- }
- return cache.get(handler);
- }
- Util.ensureHandlerId = ensureHandlerId;
- function getHandlerId(handler) {
- return cache.get(handler);
- }
- Util.getHandlerId = getHandlerId;
- function removeHandlerId(handler) {
- return cache.delete(handler);
- }
- Util.removeHandlerId = removeHandlerId;
- function setHandlerId(handler, id) {
- return cache.set(handler, id);
- }
- Util.setHandlerId = setHandlerId;
- })(Util = exports.Util || (exports.Util = {}));
- (function (Util) {
- function getHandlerQueue(elem, event) {
- const queue = [];
- const store = store_1.Store.get(elem);
- const bag = store && store.events && store.events[event.type];
- const handlers = (bag && bag.handlers) || [];
- const delegateCount = bag ? bag.delegateCount : 0;
- if (delegateCount > 0 &&
- // Support: Firefox <=42 - 66+
- // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
- // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
- // Support: IE 11+
- // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
- !(event.type === 'click' &&
- typeof event.button === 'number' &&
- event.button >= 1)) {
- for (let curr = event.target; curr !== elem; curr = curr.parentNode || elem) {
- // Don't check non-elements
- // Don't process clicks on disabled elements
- if (curr.nodeType === 1 &&
- !(event.type === 'click' && curr.disabled === true)) {
- const matchedHandlers = [];
- const matchedSelectors = {};
- for (let i = 0; i < delegateCount; i += 1) {
- const handleObj = handlers[i];
- const selector = handleObj.selector;
- if (selector != null && matchedSelectors[selector] == null) {
- const node = elem;
- const nodes = [];
- node.querySelectorAll(selector).forEach((child) => {
- nodes.push(child);
- });
- matchedSelectors[selector] = nodes.includes(curr);
- }
- if (matchedSelectors[selector]) {
- matchedHandlers.push(handleObj);
- }
- }
- if (matchedHandlers.length) {
- queue.push({ elem: curr, handlers: matchedHandlers });
- }
- }
- }
- }
- // Add the remaining (directly-bound) handlers
- if (delegateCount < handlers.length) {
- queue.push({ elem, handlers: handlers.slice(delegateCount) });
- }
- return queue;
- }
- Util.getHandlerQueue = getHandlerQueue;
- })(Util = exports.Util || (exports.Util = {}));
- (function (Util) {
- function isWindow(obj) {
- return obj != null && obj === obj.window;
- }
- Util.isWindow = isWindow;
- })(Util = exports.Util || (exports.Util = {}));
- (function (Util) {
- function contains(a, b) {
- const adown = a.nodeType === 9 ? a.documentElement : a;
- const bup = b && b.parentNode;
- return (a === bup ||
- !!(bup &&
- bup.nodeType === 1 &&
- // Support: IE 9 - 11+
- // IE doesn't have `contains` on SVG.
- (adown.contains
- ? adown.contains(bup)
- : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)));
- }
- Util.contains = contains;
- })(Util = exports.Util || (exports.Util = {}));
- //# sourceMappingURL=util.js.map
|