angular/packages/forms/test
Kristiyan Kostadinov ebf2fc5224 fix(forms): incorrectly keeping track of ngModel with ngFor inside a form (#40459)
When an `NgModel` is created within a `form`, it receives an `NgControl` based on its `name`, but
the control doesn't get swapped out if the name changes. This can lead to problems if the `NgModel`
is part of an `ngFor`, because the name can change based on its position in the list and a new
control can be defined with the same name, leading us to having multiple directives pointing to
the same control. For example, if we start off with a list like :

```
[0, 1, 2]; -> [NgModel(0), NgModel(1), NgModel(2)]
```

Then we remove the second item:

```
[0, 2]; -> [NgModel(0), NgModel(2)]
```

And finally, if we decide to add an item to the end of the list, we'll already have a control for
index 2, causing the list to look like:

```
[0, 2, 3]; -> [NgModel(0), NgModel(2), NgModel(2)]
```

These changes fix the issue by removing the old control when the `name` of the directive changes.

Fixes #38465.
Fixes #37920.

PR Close #40459
2022-02-07 13:16:10 -08:00
..
BUILD.bazel build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
directives_spec.ts test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
form_array_spec.ts feat(forms): support negative indices in FormArray methods. (#44848) 2022-01-28 16:58:29 +00:00
form_builder_spec.ts test(forms): Add more tests for FormBuilder method argument shapes. (#44452) 2021-12-14 16:11:29 -05:00
form_control_spec.ts refactor(forms): Move FormControl to an overridden exported constructor. (#44316) (#44806) 2022-01-31 22:48:23 +00:00
form_group_spec.ts refactor(forms): use shared RuntimeError class (#44398) 2022-01-06 23:43:19 +00:00
reactive_integration_spec.ts refactor(forms): update required validator and checkbox validator to inherit abstractValidator (#44162) 2022-01-24 14:50:57 -08:00
template_integration_spec.ts fix(forms): incorrectly keeping track of ngModel with ngFor inside a form (#40459) 2022-02-07 13:16:10 -08:00
util.ts refactor(forms): refactor common validators used in unit tests (#38020) 2020-07-22 20:42:43 -07:00
validators_spec.ts fix(forms): Correct empty validator to handle objects with a property length: 0. (#33729) 2022-02-03 23:15:27 -08:00
value_accessor_integration_spec.ts fix(forms): ensure OnPush ancestors are marked dirty when the promise resolves (#44886) 2022-01-31 21:38:39 +00:00