@@ -20,9 +20,9 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
20
20
final NgAnimate _animate;
21
21
dom.Element _element;
22
22
23
- final Map < String , List < NgControl >> errors = new Map <String , List < NgControl >>();
24
- final List < NgControl > _controls = new List <NgControl >();
25
- final Map < String , List < NgControl >> _controlByName = new Map <String , List <NgControl >>();
23
+ final errors = new Map <String , Set < NgModel >>();
24
+ final _controls = new List <NgControl >();
25
+ final _controlByName = new Map <String , List <NgControl >>();
26
26
27
27
NgControl (dom.Element this ._element, Injector injector,
28
28
NgAnimate this ._animate)
@@ -172,30 +172,23 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
172
172
* * [isValid] - Whether the given error is valid or not (false would mean the
173
173
* error is real).
174
174
*/
175
- updateControlValidity (NgControl control, String errorType, bool isValid) {
176
- List queue = errors[errorType];
177
-
175
+ updateControlValidity (NgControl ngModel, String errorType, bool isValid) {
178
176
if (isValid) {
179
- if (queue != null ) {
180
- queue.remove (control);
181
- if (queue.isEmpty) {
177
+ if (errors.containsKey (errorType)) {
178
+ Set errorsByName = errors[errorType];
179
+ errorsByName.remove (ngModel);
180
+ if (errorsByName.isEmpty) {
182
181
errors.remove (errorType);
183
- _parentControl.updateControlValidity (this , errorType, true );
184
182
}
185
183
}
186
184
if (errors.isEmpty) {
187
185
valid = true ;
188
186
}
189
187
} else {
190
- if (queue == null ) {
191
- queue = new List <NgControl >();
192
- errors[errorType] = queue;
193
- _parentControl.updateControlValidity (this , errorType, false );
194
- } else if (queue.contains (control)) return ;
195
-
196
- queue.add (control);
188
+ errors.putIfAbsent (errorType, () => new Set ()).add (ngModel);
197
189
invalid = true ;
198
190
}
191
+ _parentControl.updateControlValidity (ngModel, errorType, valid);
199
192
}
200
193
}
201
194
0 commit comments