refactor(compiler): attribute ast records span of the value (#12132)

This commit is contained in:
Chuck Jazdzewski
2016-10-07 13:53:29 -07:00
committed by Tobias Bosch
parent 16cfb88c00
commit 709a6dea06
3 changed files with 19 additions and 2 deletions

View File

@ -34,7 +34,9 @@ export class ExpansionCase implements Node {
}
export class Attribute implements Node {
constructor(public name: string, public value: string, public sourceSpan: ParseSourceSpan) {}
constructor(
public name: string, public value: string, public sourceSpan: ParseSourceSpan,
public valueSpan?: ParseSourceSpan) {}
visit(visitor: Visitor, context: any): any { return visitor.visitAttribute(this, context); }
}

View File

@ -331,12 +331,15 @@ class _TreeBuilder {
const fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
let end = attrName.sourceSpan.end;
let value = '';
let valueSpan: ParseSourceSpan;
if (this._peek.type === lex.TokenType.ATTR_VALUE) {
const valueToken = this._advance();
value = valueToken.parts[0];
end = valueToken.sourceSpan.end;
valueSpan = valueToken.sourceSpan;
}
return new html.Attribute(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end));
return new html.Attribute(
fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan);
}
private _getParentElement(): html.Element {