mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
feat(ngMaxlength): add support for disabling max length limit
Previously, setting the maxlength to a negative number, would make all input values invalid (since their length should be less than maxlength, which is impossible). This commit changes the behaviour of maxlength/ngMaxlength, effectively disabling the maxlength validation (always returning true) when maxlength is set to a negative number. This is more inline to how the HTML5 `maxlength` attribute works (both in browsers and according to the spec: http://dev.w3.org/html5/spec-preview/attributes-common-to-form-controls.html#attr-fe-maxlength). Related to #9874 Closes #9995
This commit is contained in:
committed by
Pawel Kozlowski
parent
891acf4c20
commit
5c1fdff691
@@ -2495,6 +2495,16 @@ describe('input', function() {
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
it('should accept values of any length when maxlength is negative', function() {
|
||||
compileInput('<input type="text" ng-model="value" ng-maxlength="-1" />');
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(inputElm).toBeValid();
|
||||
|
||||
changeInputValueTo('aaaaaaaaaa');
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
it('should listen on ng-maxlength when maxlength is observed', function() {
|
||||
var value = 0;
|
||||
compileInput('<input type="text" ng-model="value" ng-maxlength="max" attr-capture />');
|
||||
|
||||
Reference in New Issue
Block a user