angular/packages/forms/src
Andrew Kushnir 1bc53eb303 fix(forms): more precise control cleanup (#39623)
Currently when an instance of the `FormControlName` directive is destroyed, the Forms package invokes
the `cleanUpControl` to clear all directive-specific logic (such as validators, onChange handlers,
etc) from a bound control. The logic of the `cleanUpControl` function should revert all setup
performed by the `setUpControl` function. However the `cleanUpControl` is too aggressive and removes
all callbacks related to the onChange and disabled state handling. This is causing problems when
a form control is bound to multiple FormControlName` directives, causing other instances of that
directive to stop working correctly when the first one is destroyed.

This commit updates the cleanup logic to only remove callbacks added while setting up a control
for a given directive instance.

The fix is needed to allow adding `cleanUpControl` function to other places where cleanup is needed
(missing this function calls in some other places causes memory leak issues).

PR Close #39623
2020-11-12 09:38:19 -08:00
..
directives fix(forms): more precise control cleanup (#39623) 2020-11-12 09:38:19 -08:00
directives.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
form_builder.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
form_providers.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
forms.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
model.ts fix(forms): more precise control cleanup (#39623) 2020-11-12 09:38:19 -08:00
validators.ts fix(forms): remove validators while cleaning up a control (#39234) 2020-11-04 10:58:24 -08:00
version.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00