Skip to content

Commit f7816cd

Browse files
committed
Fix buggy DOM nesting warning for text components
cf. facebook#5071
1 parent 8e9682c commit f7816cd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/renderers/dom/shared/ReactDOMTextComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ assign(ReactDOMTextComponent.prototype, {
9393
if (parentInfo) {
9494
// parentInfo should always be present except for the top-level
9595
// component when server rendering
96-
validateDOMNesting(this._tag, this, parentInfo);
96+
validateDOMNesting('span', this, parentInfo);
9797
}
9898
}
9999

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,17 +926,21 @@ describe('ReactDOMComponent', function() {
926926
});
927927
var Foo = React.createClass({
928928
render: function() {
929-
return <table><Row /></table>;
929+
return <table><Row /> </table>;
930930
},
931931
});
932932
ReactTestUtils.renderIntoDocument(<Foo />);
933933

934-
expect(console.error.calls.length).toBe(1);
934+
expect(console.error.calls.length).toBe(2);
935935
expect(console.error.argsForCall[0][0]).toBe(
936936
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
937937
'<table>. See Foo > table > Row > tr. Add a <tbody> to your code to ' +
938938
'match the DOM tree generated by the browser.'
939939
);
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+
);
940944
});
941945

942946
it('gives useful context in warnings', () => {

0 commit comments

Comments
 (0)