diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index f0acb2739d4a..7acf65596a45 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -2182,6 +2182,8 @@ var ngModelDirective = function() { } element.on('blur', function(ev) { + if (modelCtrl.$touched) return; + scope.$apply(function() { modelCtrl.$setTouched(); }); diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index bf6bd70d2ecc..51e2d9e0e6f6 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -472,6 +472,23 @@ describe('ngModel', function() { dealoc(element); })); + it('should not cause a digest on "blur" event if control is already touched', + inject(function($compile, $rootScope) { + + var element = $compile('
')($rootScope); + var inputElm = element.find('input'); + var control = $rootScope.myForm.myControl; + + control.$setTouched(); + spyOn($rootScope, '$apply'); + browserTrigger(inputElm, 'blur'); + + expect($rootScope.$apply).not.toHaveBeenCalled(); + + dealoc(element); + })); it('should register/deregister a nested ngModel with parent form when entering or leaving DOM', inject(function($compile, $rootScope) {