From d84a43c82897b2aa6a083311c731191b4ae48f0f Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 8 Jul 2016 10:09:49 -0700 Subject: [PATCH] fix(TemplateParser): add support for data-template attribute fixes #9904 --- modules/@angular/compiler/src/template_parser.ts | 2 +- modules/@angular/compiler/test/template_parser_spec.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/@angular/compiler/src/template_parser.ts b/modules/@angular/compiler/src/template_parser.ts index 8cda2520cd..fcc4c16a24 100644 --- a/modules/@angular/compiler/src/template_parser.ts +++ b/modules/@angular/compiler/src/template_parser.ts @@ -431,7 +431,7 @@ class TemplateParseVisitor implements HtmlAstVisitor { attr: HtmlAttrAst, targetMatchableAttrs: string[][], targetProps: BoundElementOrDirectiveProperty[], targetVars: VariableAst[]): boolean { let templateBindingsSource: string = null; - if (attr.name == TEMPLATE_ATTR) { + if (this._normalizeAttributeName(attr.name) == TEMPLATE_ATTR) { templateBindingsSource = attr.value; } else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) { const key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length); // remove the star diff --git a/modules/@angular/compiler/test/template_parser_spec.ts b/modules/@angular/compiler/test/template_parser_spec.ts index e1db43c89a..69f523559c 100644 --- a/modules/@angular/compiler/test/template_parser_spec.ts +++ b/modules/@angular/compiler/test/template_parser_spec.ts @@ -949,6 +949,12 @@ Reference "#a" is defined several times ("
]#a>
]))).toEqual([[EmbeddedTemplateAst], [ElementAst, 'div']]); }); + it('should wrap the element with data-template attribute into an EmbeddedTemplateAST ', + () => { + expect(humanizeTplAst(parse('
', [ + ]))).toEqual([[EmbeddedTemplateAst], [ElementAst, 'div']]); + }); + it('should parse bound properties', () => { expect(humanizeTplAst(parse('
', [ngIf]))).toEqual([ [EmbeddedTemplateAst], [DirectiveAst, ngIf],