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.
This commit is contained in:
Ruslan Lesiutin
2025-12-11 12:15:00 +00:00
committed by GitHub
parent 5a970933c0
commit 37bcdcde04

View File

@@ -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.