Skip to content

Commit 37bcdcd

Browse files
authored
fix[devtools]: feature-check document with typeof instead of direct reference (#35343)
Follow-up to #35296. We can get `ReferenceError` if this is unavailable. Using `typeof` check instead for safety.
1 parent 5a97093 commit 37bcdcd

File tree

1 file changed

+5
-2
lines changed
  • packages/react-devtools-shared/src/backend/views/Highlighter

1 file changed

+5
-2
lines changed

packages/react-devtools-shared/src/backend/views/Highlighter/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ export default function setupHighlighter(
9696
applyingScroll = false;
9797
}
9898

99-
// $FlowFixMe[method-unbinding]
100-
if (document && typeof document.addEventListener === 'function') {
99+
if (
100+
typeof document === 'object' &&
101+
// $FlowFixMe[method-unbinding]
102+
typeof document.addEventListener === 'function'
103+
) {
101104
document.addEventListener('scroll', () => {
102105
if (!scrollTimer) {
103106
// Periodically synchronize the scroll while scrolling.

0 commit comments

Comments
 (0)