Skip to content

Commit

Permalink
Fix buggy DOM nesting warning for text components
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits committed Oct 16, 2015
1 parent 8e9682c commit f7816cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/ReactDOMTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit f7816cd

Please sign in to comment.