Skip to content

Commit

Permalink
Removed validateLater
Browse files Browse the repository at this point in the history
  • Loading branch information
matsko committed May 27, 2014
1 parent 2a168a5 commit b7ec365
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
22 changes: 0 additions & 22 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1770,28 +1770,6 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
});
};

/**
* @ngdoc method
* @name ngModel.NgModelController#$validateLater
*
* @description
* Sets up a validation to be run within the next digest operation. This is useful for when
* multiple changes are applied to a model without triggering a validation to take place after
* each update to the value has been applied. It is also useful to signal a revalidation when
* the inner logic of one or more validators changes (this way multiple validations are not
* applied in between).
*/
this.$validateLater = function() {
if(!ctrl.$$deferValidation) {
ctrl.$$deferValidation = true;
$scope.$$postDigest(function() {
if(ctrl.$$deferValidation) {
ctrl.$validate();
}
});
}
};

/**
* @ngdoc method
* @name ngModel.NgModelController#$commitViewValue
Expand Down
30 changes: 0 additions & 30 deletions test/ng/directive/inputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,36 +280,6 @@ describe('NgModelController', function() {
expect(ctrl.$valid).toBe(true);
});

it('should perform validations after a single digest when $validateLater is called', function() {
var validationSpy = jasmine.createSpy('validation');
ctrl.$validators.counter = function(value) {
validationSpy();
return true;
};

ctrl.$validateLater();
expect(validationSpy.callCount).toBe(0);
scope.$digest();
expect(validationSpy.callCount).toBe(1);
});

it('should not run a validation later on if a validation is run in between', function() {
scope.value = 123;
scope.$digest();

var validationSpy = jasmine.createSpy('validation');
ctrl.$validators.counter = validationSpy;

ctrl.$validateLater();
expect(validationSpy.callCount).toBe(0);

ctrl.$validate();
expect(validationSpy.callCount).toBe(1);

scope.$digest();
expect(validationSpy.callCount).toBe(1);
});

it('should always perform validations using the parsed model value', function() {
var expectedSpy = jasmine.createSpy('expected value');

Expand Down

0 comments on commit b7ec365

Please sign in to comment.