Code style fix.

This commit is contained in:
Mike Cao 2023-04-20 15:19:09 -07:00
parent 5bfbc71e7f
commit 1baf4d5571

View File

@ -12,7 +12,6 @@
if (!currentScript) return; if (!currentScript) return;
const delayDuration = 300;
const _data = 'data-'; const _data = 'data-';
const _false = 'false'; const _false = 'false';
const attr = currentScript.getAttribute.bind(currentScript); const attr = currentScript.getAttribute.bind(currentScript);
@ -29,6 +28,7 @@
const screen = `${width}x${height}`; const screen = `${width}x${height}`;
const eventRegex = /data-umami-event-([\w-_]+)/; const eventRegex = /data-umami-event-([\w-_]+)/;
const eventNameAttribute = _data + 'umami-event'; const eventNameAttribute = _data + 'umami-event';
const delayDuration = 300;
/* Helper functions */ /* Helper functions */
@ -115,18 +115,16 @@
const findATagParent = (rootElem, maxSearchDepth) => { const findATagParent = (rootElem, maxSearchDepth) => {
let currentElement = rootElem; let currentElement = rootElem;
for (let i = 0; i < maxSearchDepth; i++) { for (let i = 0; i < maxSearchDepth; i++) {
if (currentElement.tagName === 'A') if (currentElement.tagName === 'A') {
return currentElement; return currentElement;
}
currentElement = currentElement.parentElement; currentElement = currentElement.parentElement;
} }
return null; return null;
}; };
const el = e.target; const el = e.target;
const anchor = const anchor = el.tagName === 'A' ? el : findATagParent(el, 5);
el.tagName === 'A'
? el
: findATagParent(el, 5);
if (anchor) { if (anchor) {
const { href, target } = anchor; const { href, target } = anchor;