fix(compiler): don't access view local variables nor pipes in host expressions (#12396)
Fixes #12004 Closes #12071
This commit is contained in:

committed by
Alex Rickabaugh

parent
69ad99dca6
commit
867494a060
@ -74,7 +74,10 @@ export function main() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw Error(`Expected an error containing "${message}" to be reported`);
|
||||
const errMsgs = ast.errors.map(err => err.message).join('\n');
|
||||
throw Error(
|
||||
`Expected an error containing "${message}" to be reported, but got the errors:\n` +
|
||||
errMsgs);
|
||||
}
|
||||
|
||||
function expectActionError(text: string, message: string) {
|
||||
@ -504,16 +507,10 @@ export function main() {
|
||||
validate(p);
|
||||
});
|
||||
|
||||
it('should parse a constant', () => {
|
||||
var p = parseSimpleBinding('[1, 2]');
|
||||
expect(unparse(p)).toEqual('[1, 2]');
|
||||
validate(p);
|
||||
});
|
||||
|
||||
it('should report when the given expression is not just a field name', () => {
|
||||
it('should report when encountering pipes', () => {
|
||||
expectError(
|
||||
validate(parseSimpleBinding('name + 1')),
|
||||
'Host binding expression can only contain field access and constants');
|
||||
validate(parseSimpleBinding('a | somePipe')),
|
||||
'Host binding expression cannot contain pipes');
|
||||
});
|
||||
|
||||
it('should report when encountering interpolation', () => {
|
||||
@ -521,6 +518,10 @@ export function main() {
|
||||
validate(parseSimpleBinding('{{exp}}')),
|
||||
'Got interpolation ({{}}) where expression was expected');
|
||||
});
|
||||
|
||||
it('should report when encountering field write', () => {
|
||||
expectError(validate(parseSimpleBinding('a = b')), 'Bindings cannot contain assignments');
|
||||
});
|
||||
});
|
||||
|
||||
describe('wrapLiteralPrimitive', () => {
|
||||
|
Reference in New Issue
Block a user