Script simplification: Less nesting

This commit is contained in:
Ali Khaleqi Yekta
2025-05-04 12:18:49 +03:30
parent b26fc15fa0
commit 5369144b64

View File

@@ -86,9 +86,6 @@
};
const handleClicks = () => {
document.addEventListener(
'click',
async e => {
const trackElement = async el => {
const attr = el.getAttribute.bind(el);
const eventName = attr(eventNameAttribute);
@@ -103,7 +100,7 @@
return track(eventName, eventData);
}
};
const onClick = async e => {
const el = e.target;
const parentElement = el.closest('a,button');
if (!parentElement) return trackElement(el);
@@ -129,9 +126,8 @@
}
});
}
},
true,
);
};
document.addEventListener('click', onClick, true);
};
/* Tracking functions */