fix(forms): support dots in control names in contains (#11542)

Closes #11535
This commit is contained in:
Kara 2016-09-12 15:15:50 -07:00 committed by Evan Martin
parent 220d8377fe
commit 79055f727b
2 changed files with 8 additions and 2 deletions

View File

@ -626,8 +626,7 @@ export class FormGroup extends AbstractControl {
* Check whether there is a control with the given name in the group. * Check whether there is a control with the given name in the group.
*/ */
contains(controlName: string): boolean { contains(controlName: string): boolean {
const c = StringMapWrapper.contains(this.controls, controlName); return this.controls.hasOwnProperty(controlName) && this.controls[controlName].enabled;
return c && this.get(controlName).enabled;
} }
setValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void { setValue(value: {[key: string]: any}, {onlySelf}: {onlySelf?: boolean} = {}): void {

View File

@ -569,6 +569,13 @@ export function main() {
expect(group.contains('optional')).toEqual(true); expect(group.contains('optional')).toEqual(true);
}); });
it('should support controls with dots in their name', () => {
expect(group.contains('some.name')).toBe(false);
group.addControl('some.name', new FormControl());
expect(group.contains('some.name')).toBe(true);
});
}); });