From 698d4d2687b7514f7afb5b96d9ae954c569d71f6 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 21 Jan 2022 14:49:18 -0800 Subject: [PATCH] Update className check in tracker. --- tracker/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tracker/index.js b/tracker/index.js index 5d537d2c..97976ec0 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -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 => {