Inject the runtime to a global instead of exposing internals
See https://github.com/facebook/react-devtools/commit/673de20a4a0654ab849575307b9cf87fde53439e
Sebastian Markbage committed
Oct 13, 2014 at 11:59 UTC
ce19af9d304bb0b2c9b3fabf6b999c45be5b7b72
1 file changed
+24
-16
src/browser/ui/React.js
+24
-16
@@ -83,16 +83,6 @@ var React = {
83
isValidClass: ReactLegacyElement.isValidFactory,
84
isValidElement: ReactElement.isValidElement,
85
withContext: ReactContext.withContext,
86
- __internals: {
87
- Component: ReactComponent,
88
- CurrentOwner: ReactCurrentOwner,
89
- DOMComponent: ReactDOMComponent,
90
- DOMPropertyOperations: DOMPropertyOperations,
91
- InstanceHandles: ReactInstanceHandles,
92
- Mount: ReactMount,
93
- MultiChild: ReactMultiChild,
94
- TextComponent: ReactTextComponent
95
- },
86
87
// Deprecations (remove for 0.13)
88
renderComponent: deprecated(
@@ -125,18 +115,36 @@ var React = {
115
)
116
};
117
118
+// Inject the runtime into a devtools global hook regardless of browser.
119
+// Allows for debugging when the hook is injected on the page.
120
+if (
121
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
122
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
123
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
124
+ Component: ReactComponent,
125
+ CurrentOwner: ReactCurrentOwner,
126
+ DOMComponent: ReactDOMComponent,
127
+ DOMPropertyOperations: DOMPropertyOperations,
128
+ InstanceHandles: ReactInstanceHandles,
129
+ Mount: ReactMount,
130
+ MultiChild: ReactMultiChild,
131
+ TextComponent: ReactTextComponent
132
+ });
133
+}
134
+
135
if (__DEV__) {
136
var ExecutionEnvironment = require('ExecutionEnvironment');
137
if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
138
139
// If we're in Chrome, look for the devtools marker and provide a download
140
// link if not installed.
134
- if (navigator.userAgent.indexOf('Chrome') > -1 &&
135
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
136
- console.debug(
137
- 'If you haven\'t already, download the React DevTools for a better ' +
138
- 'development experience: http://fb.me/react-devtools'
139
- );
141
+ if (navigator.userAgent.indexOf('Chrome') > -1) {
142
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
143
+ console.debug(
144
+ 'Download the React DevTools for a better development experience: ' +
145
+ 'http://fb.me/react-devtools'
146
+ );
147
+ }
148
}
149
150
var expectedFeatures = [