Skip to content

Commit

Permalink
Update className check in tracker.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Jan 21, 2022
1 parent 547eefa commit 698d4d2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tracker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,16 @@ import { removeTrailingSlash } from '../lib/url';
};

const addEvent = element => {
element.className &&
element.className.split(' ').forEach(className => {
if (!eventClass.test(className)) return;
(element.getAttribute('class') || '').split(' ').forEach(className => {
if (!eventClass.test(className)) return;

const [, type, value] = className.split('--');
const listener = listeners[className]
? listeners[className]
: (listeners[className] = () => trackEvent(value, type));
const [, type, value] = className.split('--');
const listener = listeners[className]
? listeners[className]
: (listeners[className] = () => trackEvent(value, type));

element.addEventListener(type, listener, true);
});
element.addEventListener(type, listener, true);
});
};

const monitorMutate = mutations => {
Expand Down

0 comments on commit 698d4d2

Please sign in to comment.