fix(compiler): throw an error if variable with the same name is already defined. (#7209)

* fix(compiler): throw an error if variable with the same name is already defined. Closes #6492

* fix(compiler): Clean up formatting for issue #6492

* fix(compiler): throw an error if reference with the same name is already defined.

Closes #6492
This commit is contained in:
Andrii Nechytailov
2016-05-26 23:04:17 +03:00
committed by Miško Hevery
parent 263122ea5f
commit 9036f78b74
3 changed files with 40 additions and 5 deletions

View File

@ -822,6 +822,16 @@ There is no directive with "exportAs" set to "dirA" ("<div [ERROR ->]#a="dirA"><
"let-" is only supported on template elements. ("<div [ERROR ->]let-a></div>"): TestComp@0:5`);
});
it('should report duplicate reference names', () => {
expect(() => parse('<div #a></div><div #a></div>', []))
.toThrowError(`Template parse errors:
Reference "#a" is defined several times ("<div #a></div><div [ERROR ->]#a></div>"): TestComp@0:19`);
});
it('should not throw error when there is same reference name in different templates', () => {
expect(() => parse('<div #a><template #a><span>OK</span></template></div>', [])).not.toThrowError();
});
it('should assign references with empty value to components', () => {
var dirA = CompileDirectiveMetadata.create({
selector: '[a]',