@@ -11,5 +11,36 @@ To hack on the plugin:
1111
1212Generally, changes to the UI will auto-propagate if you have ` webpack --watch `
1313on (close devtools and re-open them). If you change the background script or
14- injector, you'll have to reload the extension from the extensions page.
14+ injector, you might have to reload the extension from the extensions page.
15+
16+ ## Insulating the environment
17+
18+ React Devtools has part of the code (the backend + agent) running in the same
19+ javascript context as the inspected page, which makes the code vulnerable to
20+ environmental inconsistencies. For example, the backend uses the es6 ` Map `
21+ class and normally expects it to be available in the global scope. If a user
22+ script has overridden this, the backend breaks.
23+
24+ To prevent this, the content script [ ` src/GlobalHook.js ` ] ( src/GlobalHook.js ) ,
25+ which runs before any user js, saves the native values we depend on to the
26+ ` __REACT_DEVTOOLS_GLOBAL_HOOK__ ` global. These are:
27+
28+ - Set
29+ - Map
30+ - WeakMap
31+ - Object.create
32+
33+ Then in ` webpack.backend.js ` , these saved values are substituted for the
34+ globally referenced name (e.g. ` Map ` gets replaced with
35+ ` window.__REACT_DEVTOOLS_GLOBAL_HOOK__.nativeMap ` ).
36+
37+ ## Fixing document.create
38+
39+ React Native sets ` document.createElement ` to ` null ` in order to convince js
40+ libs that they are not running in a browser environment while `debug in
41+ chrome` is enabled.
42+
43+ To deal with this, [ ` src/inject.js ` ] ( src/inject.js ) calls
44+ ` document.constructor.prototype.createElement ` when it needs to create a
45+ ` <script> ` tag.
1546
0 commit comments