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
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user