fix(forms): properly handle special properties in FormGroup.get (#22249)

closes #17195

PR Close #22249
This commit is contained in:
Trotyl 2018-04-07 15:11:02 +08:00 committed by Victor Berchet
parent 87b16710e7
commit 9367e91402
2 changed files with 13 additions and 1 deletions

View File

@ -44,7 +44,7 @@ function _find(control: AbstractControl, path: Array<string|number>| string, del
return (<Array<string|number>>path).reduce((v: AbstractControl, name) => {
if (v instanceof FormGroup) {
return v.controls[name] || null;
return v.controls.hasOwnProperty(name as string) ? v.controls[name] : null;
}
if (v instanceof FormArray) {

View File

@ -629,6 +629,18 @@ import {of } from 'rxjs';
});
});
describe('retrieve', () => {
let group: FormGroup;
beforeEach(() => {
group = new FormGroup({
'required': new FormControl('requiredValue'),
});
});
it('should not get inherited properties',
() => { expect(group.get('constructor')).toBe(null); });
});
describe('statusChanges', () => {
let control: FormControl;