fix(forms): check if registerOnValidatorChange exists on validator before trying to invoke it (#12801)
closes #12593
This commit is contained in:
parent
458ca7112a
commit
ef881475e9
|
@ -77,9 +77,19 @@ export function setUpControl(control: FormControl, dir: NgControl): void {
|
||||||
export function cleanUpControl(control: FormControl, dir: NgControl) {
|
export function cleanUpControl(control: FormControl, dir: NgControl) {
|
||||||
dir.valueAccessor.registerOnChange(() => _noControlError(dir));
|
dir.valueAccessor.registerOnChange(() => _noControlError(dir));
|
||||||
dir.valueAccessor.registerOnTouched(() => _noControlError(dir));
|
dir.valueAccessor.registerOnTouched(() => _noControlError(dir));
|
||||||
dir._rawValidators.forEach((validator: Validator) => validator.registerOnValidatorChange(null));
|
|
||||||
dir._rawAsyncValidators.forEach(
|
dir._rawValidators.forEach((validator: any) => {
|
||||||
(validator: Validator) => validator.registerOnValidatorChange(null));
|
if (validator.registerOnValidatorChange) {
|
||||||
|
validator.registerOnValidatorChange(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dir._rawAsyncValidators.forEach((validator: any) => {
|
||||||
|
if (validator.registerOnValidatorChange) {
|
||||||
|
validator.registerOnValidatorChange(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (control) control._clearChangeFns();
|
if (control) control._clearChangeFns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue