fix(TemplateParser): add support for data-template attribute
fixes #9904
This commit is contained in:
parent
9a1babb30c
commit
d84a43c828
|
@ -431,7 +431,7 @@ class TemplateParseVisitor implements HtmlAstVisitor {
|
||||||
attr: HtmlAttrAst, targetMatchableAttrs: string[][],
|
attr: HtmlAttrAst, targetMatchableAttrs: string[][],
|
||||||
targetProps: BoundElementOrDirectiveProperty[], targetVars: VariableAst[]): boolean {
|
targetProps: BoundElementOrDirectiveProperty[], targetVars: VariableAst[]): boolean {
|
||||||
let templateBindingsSource: string = null;
|
let templateBindingsSource: string = null;
|
||||||
if (attr.name == TEMPLATE_ATTR) {
|
if (this._normalizeAttributeName(attr.name) == TEMPLATE_ATTR) {
|
||||||
templateBindingsSource = attr.value;
|
templateBindingsSource = attr.value;
|
||||||
} else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) {
|
} else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) {
|
||||||
const key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length); // remove the star
|
const key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length); // remove the star
|
||||||
|
|
|
@ -949,6 +949,12 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
||||||
]))).toEqual([[EmbeddedTemplateAst], [ElementAst, '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', () => {
|
it('should parse bound properties', () => {
|
||||||
expect(humanizeTplAst(parse('<div template="ngIf test">', [ngIf]))).toEqual([
|
expect(humanizeTplAst(parse('<div template="ngIf test">', [ngIf]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [DirectiveAst, ngIf],
|
[EmbeddedTemplateAst], [DirectiveAst, ngIf],
|
||||||
|
|
Loading…
Reference in New Issue