Fix buggy DOM nesting warning for text components

cf. #5071
This commit is contained in:
Ben Alpert
2015-10-16 11:36:16 -07:00
parent 8e9682c542
commit f7816cdbfe
2 changed files with 7 additions and 3 deletions
@@ -93,7 +93,7 @@ assign(ReactDOMTextComponent.prototype, {
if (parentInfo) {
// parentInfo should always be present except for the top-level
// component when server rendering
validateDOMNesting(this._tag, this, parentInfo);
validateDOMNesting('span', this, parentInfo);
}
}
@@ -926,17 +926,21 @@ describe('ReactDOMComponent', function() {
});
var Foo = React.createClass({
render: function() {
return <table><Row /></table>;
return <table><Row /> </table>;
},
});
ReactTestUtils.renderIntoDocument(<Foo />);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls.length).toBe(2);
expect(console.error.argsForCall[0][0]).toBe(
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<table>. See Foo > table > Row > tr. Add a <tbody> to your code to ' +
'match the DOM tree generated by the browser.'
);
expect(console.error.argsForCall[1][0]).toBe(
'Warning: validateDOMNesting(...): <span> cannot appear as a child ' +
'of <table>. See Foo > table > span.'
);
});
it('gives useful context in warnings', () => {