From 37bcdcde044131d49f11b2f62873a200a94ec756 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin <28902667+hoxyq@users.noreply.github.com> Date: Thu, 11 Dec 2025 12:15:00 +0000 Subject: [PATCH] fix[devtools]: feature-check document with typeof instead of direct reference (#35343) Follow-up to https://github.com/facebook/react/pull/35296. We can get `ReferenceError` if this is unavailable. Using `typeof` check instead for safety. --- .../src/backend/views/Highlighter/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js index f1711e02c3..03397012b5 100644 --- a/packages/react-devtools-shared/src/backend/views/Highlighter/index.js +++ b/packages/react-devtools-shared/src/backend/views/Highlighter/index.js @@ -96,8 +96,11 @@ export default function setupHighlighter( applyingScroll = false; } - // $FlowFixMe[method-unbinding] - if (document && typeof document.addEventListener === 'function') { + if ( + typeof document === 'object' && + // $FlowFixMe[method-unbinding] + typeof document.addEventListener === 'function' + ) { document.addEventListener('scroll', () => { if (!scrollTimer) { // Periodically synchronize the scroll while scrolling.