fix(TemplateParser): add support for data-template attribute

fixes #9904
This commit is contained in:
Victor Berchet 2016-07-08 10:09:49 -07:00
parent 9a1babb30c
commit d84a43c828
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -949,6 +949,12 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
]))).toEqual([[EmbeddedTemplateAst], [ElementAst, 'div']]);
});
it('should wrap the element with data-template attribute into an EmbeddedTemplateAST ',
() => {
expect(humanizeTplAst(parse('<div data-template>', [
]))).toEqual([[EmbeddedTemplateAst], [ElementAst, 'div']]);
});
it('should parse bound properties', () => {
expect(humanizeTplAst(parse('<div template="ngIf test">', [ngIf]))).toEqual([
[EmbeddedTemplateAst], [DirectiveAst, ngIf],