From 185ab03201606629a413401dcdd23bab259d439a Mon Sep 17 00:00:00 2001 From: Mikhail Bodrov Date: Tue, 12 Sep 2023 18:41:56 +0300 Subject: [PATCH] refactor: optimize get links --- .../analytics-browser/src/plugins/file-download-tracking.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/analytics-browser/src/plugins/file-download-tracking.ts b/packages/analytics-browser/src/plugins/file-download-tracking.ts index af6e39704..7b6d7cf97 100644 --- a/packages/analytics-browser/src/plugins/file-download-tracking.ts +++ b/packages/analytics-browser/src/plugins/file-download-tracking.ts @@ -75,8 +75,7 @@ export const fileDownloadTracking = (): EnrichmentPlugin => { /\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)$/; // Adds listener to existing anchor tags - const links = Array.from(document.getElementsByTagName('a')); - links.forEach(addFileDownloadListener); + document.querySelectorAll('a').forEach(addFileDownloadListener); // Adds listener to anchor tags added after initial load /* istanbul ignore else */