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

Fix buggy DOM nesting warning for text components

cf. #5071

Ben Alpert committed Oct 16, 2015 at 11:36 UTC f7816cdbfe0ef38ed43f4354fd6d7d53c2f7efef
2 files changed +7 -3
src/renderers/dom/shared/ReactDOMTextComponent.js
+1 -1
@@ -93,7 +93,7 @@ assign(ReactDOMTextComponent.prototype, {
93 if (parentInfo) {
94 // parentInfo should always be present except for the top-level
95 // component when server rendering
96 - validateDOMNesting(this._tag, this, parentInfo);
96 + validateDOMNesting('span', this, parentInfo);
97 }
98 }
99
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+6 -2
@@ -926,17 +926,21 @@ describe('ReactDOMComponent', function() {
926 });
927 var Foo = React.createClass({
928 render: function() {
929 - return <table><Row /></table>;
929 + return <table><Row /> </table>;
930 },
931 });
932 ReactTestUtils.renderIntoDocument(<Foo />);
933
934 - expect(console.error.calls.length).toBe(1);
934 + expect(console.error.calls.length).toBe(2);
935 expect(console.error.argsForCall[0][0]).toBe(
936 'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
937 '<table>. See Foo > table > Row > tr. Add a <tbody> to your code to ' +
938 'match the DOM tree generated by the browser.'
939 );
940 + expect(console.error.argsForCall[1][0]).toBe(
941 + 'Warning: validateDOMNesting(...): <span> cannot appear as a child ' +
942 + 'of <table>. See Foo > table > span.'
943 + );
944 });
945
946 it('gives useful context in warnings', () => {