Tweak validation message, add html support

The old message made no sense if you had a > div > a or similar. I'm clearly feeling sloppy today.
This commit is contained in:
Ben Alpert
2015-03-25 17:24:13 -07:00
parent 07b7e8424d
commit 7c6694987d
2 changed files with 16 additions and 7 deletions
@@ -668,7 +668,8 @@ describe('ReactDOMComponent', function() {
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
'Warning: validateDOMNesting(...): <div> cannot contain a <tr> node.'
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<div> in this context (div > div).'
);
});
@@ -679,7 +680,8 @@ describe('ReactDOMComponent', function() {
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
'Warning: validateDOMNesting(...): <p> cannot contain a <tr> node.'
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<p> in this context (p).'
);
});
@@ -694,9 +696,10 @@ describe('ReactDOMComponent', function() {
expect(console.error.calls.length).toBe(1);
expect(console.error.calls[0].args[0]).toBe(
'Warning: validateDOMNesting(...): <table> cannot contain a <tr> ' +
'node. Add a <tbody> to your code to match the DOM tree generated by ' +
'the browser. Check the render method of `Foo`.'
'Warning: validateDOMNesting(...): <tr> cannot appear as a child of ' +
'<table> in this context (div > table). Add a <tbody> to your code ' +
'to match the DOM tree generated by the browser. Check the render ' +
'method of `Foo`.'
);
});
});
+8 -2
View File
@@ -176,6 +176,10 @@ if (__DEV__) {
tag === 'noscript' || tag === 'noframes' || tag === 'style' ||
tag === 'script' || tag === 'template'
);
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
case 'html':
return tag === 'head' || tag === 'body';
}
// Probably in the "in body" parsing mode, so we outlaw only tag combos
@@ -292,9 +296,11 @@ if (__DEV__) {
warning(
false,
'validateDOMNesting(...): <%s> cannot contain a <%s> node.%s',
parentTag,
'validateDOMNesting(...): <%s> cannot appear as a child of <%s> ' +
'in this context (%s).%s',
childTag,
parentTag,
parentStack.join(' > '),
info
);
}