feat(core): map 'for' attribute to 'htmlFor' property (#10546)
This improves ergonomics a bit by allowing people to write: `<label [for]="ctxProp"></label>`. This is similar to the existing class -> className mapping. Closes #7516
This commit is contained in:
parent
4595a61aeb
commit
634b3bb88b
|
@ -231,6 +231,7 @@ const SCHEMA:
|
|||
|
||||
const _ATTR_TO_PROP: {[name: string]: string} = {
|
||||
'class': 'className',
|
||||
'for': 'htmlFor',
|
||||
'formaction': 'formAction',
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
|
|
|
@ -217,6 +217,19 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
expect(nativeEl).not.toHaveCssClass('initial');
|
||||
});
|
||||
|
||||
it('should consume binding to htmlFor using for alias', () => {
|
||||
const template = '<label [for]="ctxProp"></label>';
|
||||
const fixture = TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.overrideComponent(MyComp, {set: {template}})
|
||||
.createComponent(MyComp);
|
||||
|
||||
const nativeEl = fixture.debugElement.children[0].nativeElement;
|
||||
fixture.debugElement.componentInstance.ctxProp = 'foo';
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(nativeEl.htmlFor).toBe('foo');
|
||||
});
|
||||
|
||||
it('should consume directive watch expression change.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<span>' +
|
||||
|
|
Loading…
Reference in New Issue