Skip to content
Permalink
Browse files

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
  • Loading branch information
n0th1ng-else authored and atscott committed Aug 22, 2019
1 parent 55b1b77 commit 687582fd99a67e55359033300ff5b6729458d9c5
@@ -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);
}
@@ -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'],

0 comments on commit 687582f

Please sign in to comment.
You can’t perform that action at this time.