Merge pull request #5694 from spicyj/div-html-nesting

Make sure div > html nesting is considered invalid
This commit is contained in:
Ben Alpert
2015-12-18 12:53:27 -08:00
2 changed files with 5 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ describe('ReactContextValidator', function() {
expect(isTagStackValid(['div', 'a', 'object', 'a'])).toBe(true);
expect(isTagStackValid(['div', 'p', 'button', 'p'])).toBe(true);
expect(isTagStackValid(['p', 'svg', 'foreignObject', 'p'])).toBe(true);
expect(isTagStackValid(['html', 'body', 'div'])).toBe(true);
// Invalid, but not changed by browser parsing so we allow them
expect(isTagStackValid(['div', 'ul', 'ul', 'li'])).toBe(true);
@@ -81,5 +82,6 @@ describe('ReactContextValidator', function() {
expect(isTagStackValid(['p', 'p'])).toBe(false);
expect(isTagStackValid(['table', 'tr'])).toBe(false);
expect(isTagStackValid(['div', 'ul', 'li', 'div', 'li'])).toBe(false);
expect(isTagStackValid(['div', 'html'])).toBe(false);
});
});

View File

@@ -186,6 +186,8 @@ if (__DEV__) {
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
case 'html':
return tag === 'head' || tag === 'body';
case '#document':
return tag === 'html';
}
// Probably in the "in body" parsing mode, so we outlaw only tag combos
@@ -212,6 +214,7 @@ if (__DEV__) {
case 'colgroup':
case 'frame':
case 'head':
case 'html':
case 'tbody':
case 'td':
case 'tfoot':