fix(parser): detect and report interpolation in expressions

Fixes #3645

Closes #3750
This commit is contained in:
Pawel Kozlowski
2015-08-20 16:34:47 +02:00
parent 5ee9630be1
commit b039ec3da3
3 changed files with 56 additions and 11 deletions

View File

@ -49,6 +49,12 @@ export function main() {
expect(process(el('<div [a]v="b"></div>'))[0]).toBe(null);
});
it('should throw when [] binding contains interpolation', () => {
expect(() => process(el('<div [a]="a + {{b()}}"></div>'))[0])
.toThrowErrorWith(
'Got interpolation ({{}}) where expression was expected at column 4 in [a + {{b()}}] in someComponent');
});
it('should detect bind- syntax', () => {
var results = process(el('<div bind-a="b"></div>'));
expect(results[0].propertyBindings.get('a').source).toEqual('b');
@ -157,6 +163,12 @@ export function main() {
expect(eventBinding.fullName).toEqual('click');
});
it('should throw when () action contains interpolation', () => {
expect(() => process(el('<div (a)="{{b()}}"></div>'))[0])
.toThrowErrorWith(
'Got interpolation ({{}}) where expression was expected at column 0 in [{{b()}}] in someComponent');
});
it('should detect on- syntax', () => {
var results = process(el('<div on-click="b()"></div>'));
var eventBinding = results[0].eventBindings[0];