diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index 556377c7dfd4..1afede7237c6 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -160,8 +160,6 @@ function FormController(element, attrs, $scope, $animate) { function clear(queue, validationToken) { form.$setValidity(validationToken, true, control); } - - parentForm.$$clearControlValidity(form); }; form.$$setPending = function(validationToken, control) { diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index 2a9657955e74..e780c615b413 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -494,6 +494,35 @@ describe('form', function() { expect(doc.find('div').hasClass('ng-valid-required')).toBe(true); }); + it('should leave the parent form invalid when deregister a removed input', function() { + doc = jqLite( + '
' + + '
' + + '' + + '' + + '
' + + '
'); + $compile(doc)(scope); + scope.inputPresent = true; + scope.$apply(); + + var parent = scope.parent, + child = scope.child, + inputA = child.inputA, + inputB = child.inputB; + + expect(parent).toBeDefined(); + expect(child).toBeDefined(); + expect(parent.$error.required).toEqual([child]); + expect(child.$error.required).toEqual([inputB, inputA]); + + //remove child input + scope.inputPresent = false; + scope.$apply(); + + expect(parent.$error.required).toEqual([child]); + expect(child.$error.required).toEqual([inputB]); + }); it('should chain nested forms in repeater', function() { doc = jqLite(