feat(compiler): add support for shorthand property declarations in templates (#42421)
Adds support for shorthand property declarations inside Angular templates. E.g. doing `{foo, bar}` instead of `{foo: foo, bar: bar}`.
Fixes #10277.
PR Close #42421
This commit is contained in:
committed by
Dylan Hunn
parent
699a8b43cb
commit
cc672f05bf
@@ -122,6 +122,23 @@ describe('parser', () => {
|
||||
expectActionError('{1234:0}', 'expected identifier, keyword, or string');
|
||||
expectActionError('{#myField:0}', 'expected identifier, keyword or string');
|
||||
});
|
||||
|
||||
it('should parse property shorthand declarations', () => {
|
||||
checkAction('{a, b, c}', '{a: a, b: b, c: c}');
|
||||
checkAction('{a: 1, b}', '{a: 1, b: b}');
|
||||
checkAction('{a, b: 1}', '{a: a, b: 1}');
|
||||
checkAction('{a: 1, b, c: 2}', '{a: 1, b: b, c: 2}');
|
||||
});
|
||||
|
||||
it('should not allow property shorthand declaration on quoted properties', () => {
|
||||
expectActionError('{"a-b"}', 'expected : at column 7');
|
||||
});
|
||||
|
||||
it('should not infer invalid identifiers as shorthand property declarations', () => {
|
||||
expectActionError('{a.b}', 'expected } at column 3');
|
||||
expectActionError('{a["b"]}', 'expected } at column 3');
|
||||
expectActionError('{1234}', ' expected identifier, keyword, or string at column 2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('member access', () => {
|
||||
|
||||
Reference in New Issue
Block a user