fix(compiler): correctly parse attributes with a dot in the name (#32256)

Previously the compiler would ignore everything in the attribute
name after the first dot. For example
<div [attr.someAttr.attrSuffix]="var"></div>
is turned into <div someAttr="varValue"></div>.

This commit ensures that whole attribute name is captured.
Now <div [attr.someAttr.attrSuffix]="var"></div>
is turned into <div someAttr.attrSuffix="varValue"></div>

PR Close #32256
This commit is contained in:
Sergey Nikitin 2019-08-22 09:45:43 +07:00 committed by atscott
parent 55b1b7745b
commit c0f69f3245
2 changed files with 11 additions and 1 deletions

View File

@ -278,7 +278,7 @@ export class BindingParser {
// Check for special cases (prefix style, attr, class)
if (parts.length > 1) {
if (parts[0] == ATTRIBUTE_PREFIX) {
boundPropertyName = parts[1];
boundPropertyName = parts.slice(1).join(PROPERTY_PARTS_SEPARATOR);
if (!skipValidation) {
this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true);
}

View File

@ -566,6 +566,16 @@ class ArrayConsole implements Console {
]);
});
it('should parse mixed case bound attributes with dot in the attribute name', () => {
expect(humanizeTplAst(parse('<div [attr.someAttr.someAttrSuffix]="v">', []))).toEqual([
[ElementAst, 'div'],
[
BoundElementPropertyAst, PropertyBindingType.Attribute, 'someAttr.someAttrSuffix',
'v', null
]
]);
});
it('should parse and dash case bound classes', () => {
expect(humanizeTplAst(parse('<div [class.some-class]="v">', []))).toEqual([
[ElementAst, 'div'],