From 64d903653bf21c9efc251a4a64727440b7c93248 Mon Sep 17 00:00:00 2001 From: "siarhei.fedarovich" Date: Fri, 27 Mar 2020 10:46:38 -0700 Subject: [PATCH] fix(performance-relayer): properly clean up event listeners on visibilitychange --- packages/next/client/performance-relayer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/client/performance-relayer.js b/packages/next/client/performance-relayer.js index 2d2c9dae326c3..2904ad5d6f569 100644 --- a/packages/next/client/performance-relayer.js +++ b/packages/next/client/performance-relayer.js @@ -25,7 +25,7 @@ export function observeLayoutShift(onPerfEntry) { // Force any pending records to be dispatched. observer.takeRecords() observer.disconnect() - removeEventListener('visibilitychange', clsObserver, true) + document.removeEventListener('visibilitychange', clsObserver, true) onPerfEntry({ name: 'cumulative-layout-shift', value: cumulativeScore, @@ -55,7 +55,7 @@ export function observeLargestContentfulPaint(onPerfEntry) { 'visibilitychange', function lcpObserver() { if (lcp && document.visibilityState === 'hidden') { - removeEventListener('visibilitychange', lcpObserver, true) + document.removeEventListener('visibilitychange', lcpObserver, true) onPerfEntry({ name: 'largest-contentful-paint', value: lcp,