Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit c16fd40

Browse files
1.8.4
1 parent e1886e7 commit c16fd40

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

dist/mask.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-ui-mask
33
* https://github.com/angular-ui/ui-mask
4-
* Version: 1.8.3 - 2016-03-30T21:12:43.955Z
4+
* Version: 1.8.4 - 2016-05-17T14:33:25.025Z
55
* License: MIT
66
*/
77

@@ -22,7 +22,8 @@ angular.module('ui.mask', [])
2222
clearOnBlurPlaceholder: false,
2323
escChar: '\\',
2424
eventsToHandle: ['input', 'keyup', 'click', 'focus'],
25-
addDefaultPlaceholder: true
25+
addDefaultPlaceholder: true,
26+
allowInvalidValue: false
2627
})
2728
.provider('uiMask.Config', function() {
2829
var options = {};
@@ -42,6 +43,9 @@ angular.module('ui.mask', [])
4243
this.addDefaultPlaceholder = function(addDefaultPlaceholder) {
4344
return options.addDefaultPlaceholder = addDefaultPlaceholder;
4445
};
46+
this.allowInvalidValue = function(allowInvalidValue) {
47+
return options.allowInvalidValue = allowInvalidValue;
48+
};
4549
this.$get = ['uiMaskConfig', function(uiMaskConfig) {
4650
var tempOptions = uiMaskConfig;
4751
for(var prop in options) {
@@ -65,7 +69,7 @@ angular.module('ui.mask', [])
6569
require: 'ngModel',
6670
restrict: 'A',
6771
compile: function uiMaskCompilingFunction() {
68-
var options = maskConfig;
72+
var options = angular.copy(maskConfig);
6973

7074
return function uiMaskLinkingFunction(scope, iElement, iAttrs, controller) {
7175
var maskProcessed = false, eventsBound = false,
@@ -132,14 +136,27 @@ angular.module('ui.mask', [])
132136
}
133137
});
134138

139+
iAttrs.$observe('allowInvalidValue', function(val) {
140+
linkOptions.allowInvalidValue = val === ''
141+
? true
142+
: !!val;
143+
formatter(controller.$modelValue);
144+
});
145+
135146
function formatter(fromModelValue) {
136147
if (!maskProcessed) {
137148
return fromModelValue;
138149
}
139150
value = unmaskValue(fromModelValue || '');
140151
isValid = validateValue(value);
141152
controller.$setValidity('mask', isValid);
142-
return isValid && value.length ? maskValue(value) : undefined;
153+
154+
if (!value.length) return undefined;
155+
if (isValid || linkOptions.allowInvalidValue) {
156+
return maskValue(value);
157+
} else {
158+
return undefined;
159+
}
143160
}
144161

145162
function parser(fromViewValue) {
@@ -154,10 +171,9 @@ angular.module('ui.mask', [])
154171
// to be out-of-sync with what the controller's $viewValue is set to.
155172
controller.$viewValue = value.length ? maskValue(value) : '';
156173
controller.$setValidity('mask', isValid);
157-
if (isValid) {
174+
175+
if (isValid || linkOptions.allowInvalidValue) {
158176
return modelViewValue ? controller.$viewValue : value;
159-
} else {
160-
return undefined;
161177
}
162178
}
163179

dist/mask.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-mask",
3-
"version": "1.8.3",
3+
"version": "1.8.4",
44
"author": "https://github.com/angular-ui/ui-mask/graphs/contributors",
55
"license": "MIT",
66
"homepage": "https://github.com/angular-ui/ui-mask",

0 commit comments

Comments
 (0)