refactor(compiler): refactor template binding parsing (#23460)

A long time ago Angular used to support both those attribute notations:
- `*attr='binding'`
- `template=`attr: binding`

Because the last notation has been dropped we can refactor the binding parsing.
Source maps will benefit from that as no `attr:` prefix is added artificialy any
more.

PR Close #23460
This commit is contained in:
Victor Berchet
2018-04-19 17:23:27 -07:00
parent ca776c59dd
commit 4662878a1f
7 changed files with 557 additions and 573 deletions

View File

@ -107,16 +107,16 @@ export class HtmlToTemplateTransform implements html.Visitor {
}
isTemplateBinding = true;
elementHasInlineTemplate = true;
const templateBindingsSource = attribute.value;
const prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':';
const templateValue = attribute.value;
const templateKey = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length);
const oldVariables: VariableAst[] = [];
inlineTemplateSourceSpan = attribute.valueSpan || attribute.sourceSpan;
this.bindingParser.parseInlineTemplateBinding(
prefixToken !, templateBindingsSource !, attribute.sourceSpan,
templateMatchableAttributes, templateBoundProperties, oldVariables);
templateKey, templateValue, attribute.sourceSpan, templateMatchableAttributes,
templateBoundProperties, oldVariables);
templateVariables.push(
...oldVariables.map(v => new t.Variable(v.name, v.value, v.sourceSpan)));