fix(Compiler): fix template binding parsing (`*directive="-..."`)
fixes #13800
This commit is contained in:
parent
d9a22dae4f
commit
e5c6bb4286
|
@ -276,7 +276,7 @@ class TemplateParseVisitor implements html.Visitor {
|
||||||
templateBindingsSource = attr.value;
|
templateBindingsSource = attr.value;
|
||||||
} else if (normalizedName.startsWith(TEMPLATE_ATTR_PREFIX)) {
|
} else if (normalizedName.startsWith(TEMPLATE_ATTR_PREFIX)) {
|
||||||
templateBindingsSource = attr.value;
|
templateBindingsSource = attr.value;
|
||||||
prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length);
|
prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasTemplateBinding = isPresent(templateBindingsSource);
|
const hasTemplateBinding = isPresent(templateBindingsSource);
|
||||||
|
|
|
@ -1323,17 +1323,30 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should work with *... and use the attribute name as property binding name', () => {
|
it('should work with *... and use the attribute name as property binding name', () => {
|
||||||
expect(humanizeTplAst(parse('<div *ngIf="test">', [ngIf]))).toEqual([
|
expect(humanizeTplAst(parse('<div *ngIf="test">', [ngIf]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [DirectiveAst, ngIf],
|
[EmbeddedTemplateAst],
|
||||||
[BoundDirectivePropertyAst, 'ngIf', 'test'], [ElementAst, 'div']
|
[DirectiveAst, ngIf],
|
||||||
|
[BoundDirectivePropertyAst, 'ngIf', 'test'],
|
||||||
|
[ElementAst, 'div'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// https://github.com/angular/angular/issues/13800
|
||||||
|
expect(humanizeTplAst(parse('<div *ngIf="-1">', [ngIf]))).toEqual([
|
||||||
|
[EmbeddedTemplateAst],
|
||||||
|
[DirectiveAst, ngIf],
|
||||||
|
[BoundDirectivePropertyAst, 'ngIf', '0 - 1'],
|
||||||
|
[ElementAst, 'div'],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with *... and empty value', () => {
|
it('should work with *... and empty value', () => {
|
||||||
expect(humanizeTplAst(parse('<div *ngIf>', [ngIf]))).toEqual([
|
expect(humanizeTplAst(parse('<div *ngIf>', [ngIf]))).toEqual([
|
||||||
[EmbeddedTemplateAst], [DirectiveAst, ngIf],
|
[EmbeddedTemplateAst],
|
||||||
[BoundDirectivePropertyAst, 'ngIf', 'null'], [ElementAst, 'div']
|
[DirectiveAst, ngIf],
|
||||||
|
[BoundDirectivePropertyAst, 'ngIf', 'null'],
|
||||||
|
[ElementAst, 'div'],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue