fix: support *directive on <template> (#9691)

fixes #7315
This commit is contained in:
Miško Hevery 2016-06-28 21:53:41 -07:00 committed by GitHub
parent 3784696b9e
commit 3fec27961e
2 changed files with 4 additions and 14 deletions

View File

@ -321,12 +321,6 @@ class TemplateParseVisitor implements HtmlAstVisitor {
var hasTemplateBinding = this._parseInlineTemplateBinding(
attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
if (hasTemplateBinding && isTemplateElement) {
this._reportError(
`Can't have template bindings on a <template> element but the '${attr.name}' attribute was used`,
attr.sourceSpan);
}
if (hasTemplateBinding && hasInlineTemplates) {
this._reportError(
`Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *`,

View File

@ -1153,15 +1153,11 @@ Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>
<ng-content> element cannot have content. <ng-content> must be immediately followed by </ng-content> ("[ERROR ->]<ng-content>content</ng-content>"): TestComp@0:0`);
});
it('should report when *attr is used on a template element', () => {
expect(() => parse('<template *ngIf>', [])).toThrowError(`Template parse errors:
Can't have template bindings on a <template> element but the '*ngIf' attribute was used ("<template [ERROR ->]*ngIf>"): TestComp@0:10`);
});
it('should treat *attr on a template element as valid',
() => { expect(() => parse('<template *ngIf>', [])).not.toThrowError(); });
it('should report when a template attribute is used on a template element', () => {
expect(() => parse('<template template="ngIf">', [])).toThrowError(`Template parse errors:
Can't have template bindings on a <template> element but the 'template' attribute was used ("<template [ERROR ->]template="ngIf">"): TestComp@0:10`);
});
it('should treat template attribute on a template element as valid',
() => { expect(() => parse('<template template="ngIf">', [])).not.toThrowError(); });
it('should report when mutliple *attrs are used on the same element', () => {
expect(() => parse('<div *ngIf *ngFor>', [])).toThrowError(`Template parse errors: