Make sure div > html nesting is considered invalid
See #5128.
Ben Alpert committed
Dec 18, 2015 at 12:39 UTC
40d5692980bccf33dd50b28e443e198d13524fb6
2 files changed
+5
src/renderers/dom/client/__tests__/validateDOMNesting-test.js
+2
@@ -67,6 +67,7 @@ describe('ReactContextValidator', function() {
67
expect(isTagStackValid(['div', 'a', 'object', 'a'])).toBe(true);
68
expect(isTagStackValid(['div', 'p', 'button', 'p'])).toBe(true);
69
expect(isTagStackValid(['p', 'svg', 'foreignObject', 'p'])).toBe(true);
70
+ expect(isTagStackValid(['html', 'body', 'div'])).toBe(true);
71
72
// Invalid, but not changed by browser parsing so we allow them
73
expect(isTagStackValid(['div', 'ul', 'ul', 'li'])).toBe(true);
@@ -81,5 +82,6 @@ describe('ReactContextValidator', function() {
82
expect(isTagStackValid(['p', 'p'])).toBe(false);
83
expect(isTagStackValid(['table', 'tr'])).toBe(false);
84
expect(isTagStackValid(['div', 'ul', 'li', 'div', 'li'])).toBe(false);
85
+ expect(isTagStackValid(['div', 'html'])).toBe(false);
86
});
87
});
src/renderers/dom/client/validateDOMNesting.js
+3
@@ -186,6 +186,8 @@ if (__DEV__) {
186
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
187
case 'html':
188
return tag === 'head' || tag === 'body';
189
+ case '#document':
190
+ return tag === 'html';
191
}
192
193
// Probably in the "in body" parsing mode, so we outlaw only tag combos
@@ -212,6 +214,7 @@ if (__DEV__) {
214
case 'colgroup':
215
case 'frame':
216
case 'head':
217
+ case 'html':
218
case 'tbody':
219
case 'td':
220
case 'tfoot':