Skip to content

Commit 5a42b97

Browse files
author
Brian Vaughn
authored
Merge branch 'master' into devtools-renable-copy-attr-context-menu-for-firefox
2 parents bf4f00e + 2b903da commit 5a42b97

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/react-devtools-extensions/src/injectGlobalHook.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,17 @@ if (sessionStorageGetItem(SESSION_STORAGE_RELOAD_AND_PROFILE_KEY) === 'true') {
8686
injectCode(rendererCode);
8787
}
8888

89-
// Inject a `__REACT_DEVTOOLS_GLOBAL_HOOK__` global so that React can detect that the
90-
// devtools are installed (and skip its suggestion to install the devtools).
91-
injectCode(
92-
';(' + installHook.toString() + '(window))' + saveNativeValues + detectReact,
93-
);
89+
// Inject a __REACT_DEVTOOLS_GLOBAL_HOOK__ global for React to interact with.
90+
// Only do this for HTML documents though, to avoid e.g. breaking syntax highlighting for XML docs.
91+
if (document.contentType === 'text/html') {
92+
injectCode(
93+
';(' +
94+
installHook.toString() +
95+
'(window))' +
96+
saveNativeValues +
97+
detectReact,
98+
);
99+
}
94100

95101
if (typeof exportFunction === 'function') {
96102
// eslint-disable-next-line no-undef
@@ -106,4 +112,4 @@ if (typeof exportFunction === 'function') {
106112
window.wrappedJSObject.__REACT_DEVTOOLS_GLOBAL_HOOK__,
107113
{defineAs: 'clipboardCopyText'},
108114
);
109-
}
115+
}

0 commit comments

Comments
 (0)