mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 13:41:50 +02:00
Allow tracker to traverse all levels to find anchor.
This commit is contained in:
parent
f450fc35fb
commit
ae85bf696b
|
@ -112,22 +112,21 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
const callback = e => {
|
const callback = e => {
|
||||||
const findATagParent = (rootElem, maxSearchDepth) => {
|
const findATagParent = rootElem => {
|
||||||
let currentElement = rootElem;
|
let currentElement = rootElem;
|
||||||
for (let i = 0; i < maxSearchDepth; i++) {
|
|
||||||
|
while (currentElement) {
|
||||||
if (currentElement.tagName === 'A') {
|
if (currentElement.tagName === 'A') {
|
||||||
return currentElement;
|
return currentElement;
|
||||||
}
|
}
|
||||||
currentElement = currentElement.parentElement;
|
currentElement = currentElement.parentElement;
|
||||||
if (currentElement === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const el = e.target;
|
const el = e.target;
|
||||||
const anchor = el.tagName === 'A' ? el : findATagParent(el, 5);
|
const anchor = el.tagName === 'A' ? el : findATagParent(el);
|
||||||
|
|
||||||
if (anchor) {
|
if (anchor) {
|
||||||
const { href, target } = anchor;
|
const { href, target } = anchor;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user