feat(HtmlParser): enforce only void & foreign elts can be self closed
BREAKING CHANGE: `<whatever />` used to be expanded to `<whatever></whatever>`. The parser now follows the HTML5 spec more closely. Only void and foreign elements can be self closed. Closes #5591
This commit is contained in:
@ -134,6 +134,11 @@ class TreeBuilder {
|
||||
if (this.peek.type === HtmlTokenType.TAG_OPEN_END_VOID) {
|
||||
this._advance();
|
||||
selfClosing = true;
|
||||
if (namespacePrefix(fullName) == null && !getHtmlTagDefinition(fullName).isVoid) {
|
||||
this.errors.push(HtmlTreeError.create(
|
||||
fullName, startTagToken.sourceSpan.start,
|
||||
`Only void and foreign elements can be self closed "${startTagToken.parts[1]}"`));
|
||||
}
|
||||
} else if (this.peek.type === HtmlTokenType.TAG_OPEN_END) {
|
||||
this._advance();
|
||||
selfClosing = false;
|
||||
|
Reference in New Issue
Block a user