From a8aeda34a0ce0187c432ddda5508dd0e689a7021 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 22 Oct 2021 05:01:31 +0000 Subject: [PATCH] Popover: Check anchorDocument default view before removing events (#35832) --- packages/components/src/popover/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/src/popover/index.js b/packages/components/src/popover/index.js index 3e2ee5db6072de..cbd74370b346e2 100644 --- a/packages/components/src/popover/index.js +++ b/packages/components/src/popover/index.js @@ -456,11 +456,11 @@ const Popover = ( defaultView.cancelAnimationFrame( rafId ); if ( anchorDocument && anchorDocument !== ownerDocument ) { - anchorDocument.defaultView.removeEventListener( + anchorDocument.defaultView?.removeEventListener( 'resize', refresh ); - anchorDocument.defaultView.removeEventListener( + anchorDocument.defaultView?.removeEventListener( 'scroll', refresh, true