refactor: remove facade/collection (#14837)
This commit is contained in:

committed by
Chuck Jazdzewski

parent
4fe0b90948
commit
b0e0839075
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
import {Directive, EventEmitter, Inject, Input, OnChanges, Optional, Output, Self, SimpleChanges, forwardRef} from '@angular/core';
|
||||
|
||||
import {ListWrapper} from '../../facade/collection';
|
||||
import {FormArray, FormControl, FormGroup} from '../../model';
|
||||
import {NG_ASYNC_VALIDATORS, NG_VALIDATORS, Validators} from '../../validators';
|
||||
import {ControlContainer} from '../control_container';
|
||||
@ -107,7 +105,7 @@ export class FormGroupDirective extends ControlContainer implements Form,
|
||||
|
||||
getControl(dir: FormControlName): FormControl { return <FormControl>this.form.get(dir.path); }
|
||||
|
||||
removeControl(dir: FormControlName): void { ListWrapper.remove(this.directives, dir); }
|
||||
removeControl(dir: FormControlName): void { remove(this.directives, dir); }
|
||||
|
||||
addFormGroup(dir: FormGroupName): void {
|
||||
const ctrl: any = this.form.get(dir.path);
|
||||
@ -181,3 +179,10 @@ export class FormGroupDirective extends ControlContainer implements Form,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove<T>(list: T[], el: T): void {
|
||||
const index = list.indexOf(el);
|
||||
if (index > -1) {
|
||||
list.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {InjectionToken, ɵisPromise as isPromise} from '@angular/core';
|
||||
import {InjectionToken, ɵisPromise as isPromise, ɵmerge as merge} from '@angular/core';
|
||||
import {toPromise} from 'rxjs/operator/toPromise';
|
||||
import {AsyncValidatorFn, Validator, ValidatorFn} from './directives/validators';
|
||||
import {StringMapWrapper} from './facade/collection';
|
||||
import {isPresent} from './facade/lang';
|
||||
import {AbstractControl, FormControl, FormGroup} from './model';
|
||||
|
||||
@ -203,7 +202,7 @@ function _executeAsyncValidators(control: AbstractControl, validators: AsyncVali
|
||||
function _mergeErrors(arrayOfErrors: any[]): {[key: string]: any} {
|
||||
const res: {[key: string]: any} =
|
||||
arrayOfErrors.reduce((res: {[key: string]: any}, errors: {[key: string]: any}) => {
|
||||
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
|
||||
return isPresent(errors) ? merge(res, errors) : res;
|
||||
}, {});
|
||||
return Object.keys(res).length === 0 ? null : res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user