Merge pull request #3934 from spicyj/gh-3921

Dedupe warnings in validateDOMNesting
This commit is contained in:
Ben Alpert committed 2015-05-22 10:33:36 -07:00
commit e1a9e429d3
2 files changed
+10 -1

No files matched your search

@@ -319,6 +319,8 @@ if (__DEV__) {
return stack;
};
var didWarn = {};
validateDOMNesting = function(childTag, childInstance, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.parentTag;
@@ -374,6 +376,13 @@ if (__DEV__) {
childTag
).join(' > ');
var warnKey =
!!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + ownerInfo;
if (didWarn[warnKey]) {
return;
}
didWarn[warnKey] = true;
if (invalidParent) {
var info = '';
if (ancestorTag === 'table' && childTag === 'tr') {
@@ -733,7 +733,7 @@ describe('ReactDOMComponent', function() {
it('warns on invalid nesting', () => {
spyOn(console, 'error');
ReactTestUtils.renderIntoDocument(<div><tr /></div>);
ReactTestUtils.renderIntoDocument(<div><tr /><tr /></div>);
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(