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:
Kristiyan Kostadinov
2021-06-19 08:07:20 +02:00
committed by Dylan Hunn
parent 699a8b43cb
commit cc672f05bf
17 changed files with 390 additions and 10 deletions
@@ -2041,6 +2041,26 @@ describe('acceptance integration tests', () => {
expect(fixture.nativeElement.innerHTML).toContain('<text>Hello</text>');
});
it('should handle shorthand property declarations in templates', () => {
@Directive({selector: '[my-dir]'})
class Dir {
@Input('my-dir') value: any;
}
@Component({template: `<div [my-dir]="{a, b: 2, someProp}"></div>`})
class App {
@ViewChild(Dir) directive!: Dir;
a = 1;
someProp = 3;
}
TestBed.configureTestingModule({declarations: [App, Dir]});
const fixture = TestBed.createComponent(App);
fixture.detectChanges();
expect(fixture.componentInstance.directive.value).toEqual({a: 1, b: 2, someProp: 3});
});
describe('tView.firstUpdatePass', () => {
function isFirstUpdatePass() {
const lView = getLView();