mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Minor tweaks.
This commit is contained in:
parent
132bbcbe0d
commit
0edf87941a
6 changed files with 24 additions and 22 deletions
|
|
@ -73,7 +73,9 @@ import 'unfetch/polyfill';
|
|||
const orig = history[type];
|
||||
return (state, title, url) => {
|
||||
const args = [state, title, url];
|
||||
|
||||
cb.apply(null, args);
|
||||
|
||||
return orig.apply(history, args);
|
||||
};
|
||||
};
|
||||
|
|
@ -85,7 +87,7 @@ import 'unfetch/polyfill';
|
|||
|
||||
const removeEvents = () => {
|
||||
listeners.forEach(([element, type, listener]) => {
|
||||
element.removeEventListener(type, listener, true);
|
||||
element && element.removeEventListener(type, listener, true);
|
||||
});
|
||||
listeners.length = 0;
|
||||
};
|
||||
|
|
@ -93,13 +95,12 @@ import 'unfetch/polyfill';
|
|||
const loadEvents = () => {
|
||||
document.querySelectorAll("[class*='umami--']").forEach(element => {
|
||||
element.className.split(' ').forEach(className => {
|
||||
if (/^umami--/.test(className)) {
|
||||
if (/^umami--([a-z]+)--([a-z0-9_]+[a-z0-9-_]+)$/.test(className)) {
|
||||
const [, type, value] = className.split('--');
|
||||
if (type && value) {
|
||||
const listener = () => pageEvent(type, value);
|
||||
listeners.push([element, type, listener]);
|
||||
element.addEventListener(type, listener, true);
|
||||
}
|
||||
const listener = () => pageEvent(type, value);
|
||||
|
||||
listeners.push([element, type, listener]);
|
||||
element.addEventListener(type, listener, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue