feat(html_parser): change HtmlElementAst to store both the start and the end positions
This commit is contained in:
@@ -154,11 +154,12 @@ class TreeBuilder {
|
||||
selfClosing = false;
|
||||
}
|
||||
var end = this.peek.sourceSpan.start;
|
||||
var el = new HtmlElementAst(fullName, attrs, [],
|
||||
new ParseSourceSpan(startTagToken.sourceSpan.start, end));
|
||||
let span = new ParseSourceSpan(startTagToken.sourceSpan.start, end);
|
||||
var el = new HtmlElementAst(fullName, attrs, [], span, span, null);
|
||||
this._pushElement(el);
|
||||
if (selfClosing) {
|
||||
this._popElement(fullName);
|
||||
el.endSourceSpan = span;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +174,8 @@ class TreeBuilder {
|
||||
var tagDef = getHtmlTagDefinition(el.name);
|
||||
var parentEl = this._getParentElement();
|
||||
if (tagDef.requireExtraParent(isPresent(parentEl) ? parentEl.name : null)) {
|
||||
var newParent = new HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan);
|
||||
var newParent = new HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan,
|
||||
el.startSourceSpan, el.endSourceSpan);
|
||||
this._addToParent(newParent);
|
||||
this.elementStack.push(newParent);
|
||||
this.elementStack.push(el);
|
||||
@@ -187,6 +189,8 @@ class TreeBuilder {
|
||||
var fullName =
|
||||
getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
|
||||
|
||||
this._getParentElement().endSourceSpan = endTagToken.sourceSpan;
|
||||
|
||||
if (getHtmlTagDefinition(fullName).isVoid) {
|
||||
this.errors.push(
|
||||
HtmlTreeError.create(fullName, endTagToken.sourceSpan,
|
||||
|
||||
Reference in New Issue
Block a user