fix(HTMLParser): properly report errors for not properly closed tags (#8999)

Fixes #7849
This commit is contained in:
Pawel Kozlowski 2016-06-03 19:49:17 +02:00 committed by Miško Hevery
parent fe8a7b0e82
commit 6f281ab3c4
2 changed files with 9 additions and 1 deletions

View File

@ -295,7 +295,9 @@ class TreeBuilder {
var fullName =
getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
this._getParentElement().endSourceSpan = endTagToken.sourceSpan;
if (this._getParentElement()) {
this._getParentElement().endSourceSpan = endTagToken.sourceSpan;
}
if (getHtmlTagDefinition(fullName).isVoid) {
this.errors.push(

View File

@ -343,6 +343,12 @@ export function main() {
expect(humanizeErrors(errors)).toEqual([['p', 'Unexpected closing tag "p"', '0:5']]);
});
it('should report subsequent open tags without proper close tag', () => {
let errors = parser.parse('<div</div>', 'TestComp').errors;
expect(errors.length).toEqual(1);
expect(humanizeErrors(errors)).toEqual([['div', 'Unexpected closing tag "div"', '0:4']]);
});
it('should report closing tag for void elements', () => {
let errors = parser.parse('<input></input>', 'TestComp').errors;
expect(errors.length).toEqual(1);