From c0f69f324548ed06ecdbd0b4d307f5585f620fe8 Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Thu, 22 Aug 2019 09:45:43 +0700 Subject: [PATCH] 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
is turned into
. This commit ensures that whole attribute name is captured. Now
is turned into
PR Close #32256 --- .../compiler/src/template_parser/binding_parser.ts | 2 +- .../test/template_parser/template_parser_spec.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/compiler/src/template_parser/binding_parser.ts b/packages/compiler/src/template_parser/binding_parser.ts index 64c6438a59..6da0d1495f 100644 --- a/packages/compiler/src/template_parser/binding_parser.ts +++ b/packages/compiler/src/template_parser/binding_parser.ts @@ -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); } diff --git a/packages/compiler/test/template_parser/template_parser_spec.ts b/packages/compiler/test/template_parser/template_parser_spec.ts index df188cc0ab..782b7d5733 100644 --- a/packages/compiler/test/template_parser/template_parser_spec.ts +++ b/packages/compiler/test/template_parser/template_parser_spec.ts @@ -566,6 +566,16 @@ class ArrayConsole implements Console { ]); }); + it('should parse mixed case bound attributes with dot in the attribute name', () => { + expect(humanizeTplAst(parse('
', []))).toEqual([ + [ElementAst, 'div'], + [ + BoundElementPropertyAst, PropertyBindingType.Attribute, 'someAttr.someAttrSuffix', + 'v', null + ] + ]); + }); + it('should parse and dash case bound classes', () => { expect(humanizeTplAst(parse('
', []))).toEqual([ [ElementAst, 'div'],