refactor: simplify isPresent(x) ? x : y to x || y (#12166)

Closes #12166
This commit is contained in:
Victor Berchet
2016-10-07 18:11:37 -07:00
committed by Tobias Bosch
parent bdcf46f82e
commit d972d82354
18 changed files with 40 additions and 43 deletions

View File

@ -52,13 +52,14 @@ function _find(control: AbstractControl, path: Array<string|number>| string, del
return (<Array<string|number>>path).reduce((v, name) => {
if (v instanceof FormGroup) {
return isPresent(v.controls[name]) ? v.controls[name] : null;
} else if (v instanceof FormArray) {
var index = <number>name;
return isPresent(v.at(index)) ? v.at(index) : null;
} else {
return null;
return v.controls[name] || null;
}
if (v instanceof FormArray) {
return v.at(<number>name) || null;
}
return null;
}, control);
}