fix(forms): properly handle special properties in FormGroup.get (#22249)
closes #17195 PR Close #22249
This commit is contained in:
parent
87b16710e7
commit
9367e91402
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue