@samitouri / QOS-React-2 / commits / e619d25d03

Inject browser mixin before full-page components

createFullPageComponent doesn't reference ReactBrowserComponentMixin directly so the mixin should get injected before the components are created. Previously, this test failed because getDOMNode wasn't present on the component instance. Test Plan: jest

Ben Alpert committed Nov 16, 2014 at 12:57 UTC e619d25d035051791e8654525bf44772abf17a74
2 files changed +21 -4
src/browser/ui/ReactDefaultInjection.js
+4 -4
@@ -78,6 +78,10 @@ function inject() {
78 ReactDOMTextComponent
79 );
80
81 + // This needs to happen before createFullPageComponent() otherwise the mixin
82 + // won't be included.
83 + ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
84 +
85 ReactInjection.NativeComponent.injectComponentClasses({
86 'button': ReactDOMButton,
87 'form': ReactDOMForm,
@@ -92,10 +96,6 @@ function inject() {
96 'body': createFullPageComponent('body')
97 });
98
95 - // This needs to happen after createFullPageComponent() otherwise the mixin
96 - // gets double injected.
97 - ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
98 -
99 ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
100 ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
101
src/browser/ui/__tests__/ReactRenderDocument-test.js
+17
@@ -244,4 +244,21 @@ describe('rendering React components at document', function() {
244 );
245 });
246
247 + it('supports getDOMNode on full-page components', function() {
248 + var tree =
249 + <html>
250 + <head>
251 + <title>Hello World</title>
252 + </head>
253 + <body>
254 + Hello world
255 + </body>
256 + </html>;
257 +
258 + var markup = React.renderToString(tree);
259 + testDocument = getTestDocument(markup);
260 + var component = React.render(tree, testDocument);
261 + expect(testDocument.body.innerHTML).toBe('Hello world');
262 + expect(component.getDOMNode().tagName).toBe('HTML');
263 + });
264 });