|
1 | 1 | /*!
|
2 | 2 | * angular-ui-mask
|
3 | 3 | * https://github.com/angular-ui/ui-mask
|
4 |
| - * Version: 1.8.4 - 2016-05-17T14:33:25.025Z |
| 4 | + * Version: 1.8.5 - 2016-06-10T16:53:59.510Z |
5 | 5 | * License: MIT
|
6 | 6 | */
|
7 | 7 |
|
@@ -87,13 +87,13 @@ angular.module('ui.mask', [])
|
87 | 87 | preventBackspace;
|
88 | 88 |
|
89 | 89 | var originalIsEmpty = controller.$isEmpty;
|
90 |
| - controller.$isEmpty = function(value) { |
91 |
| - if (maskProcessed) { |
92 |
| - return originalIsEmpty(unmaskValue(value || '')); |
93 |
| - } else { |
94 |
| - return originalIsEmpty(value); |
95 |
| - } |
96 |
| - }; |
| 90 | + controller.$isEmpty = function(value) { |
| 91 | + if (maskProcessed) { |
| 92 | + return originalIsEmpty(unmaskValue(value || '')); |
| 93 | + } else { |
| 94 | + return originalIsEmpty(value); |
| 95 | + } |
| 96 | + }; |
97 | 97 |
|
98 | 98 | function initialize(maskAttr) {
|
99 | 99 | if (!angular.isDefined(maskAttr)) {
|
@@ -463,8 +463,21 @@ angular.module('ui.mask', [])
|
463 | 463 | }
|
464 | 464 | }
|
465 | 465 | //Check for different value and trigger change.
|
| 466 | + //Check for different value and trigger change. |
466 | 467 | if (value !== prevValue) {
|
| 468 | + // #157 Fix the bug from the trigger when backspacing exactly on the first letter (emptying the field) |
| 469 | + // and then blurring out. |
| 470 | + // Angular uses html element and calls setViewValue(element.value.trim()), setting it to the trimmed mask |
| 471 | + // when it should be empty |
| 472 | + var currentVal = iElement.val(); |
| 473 | + var isTemporarilyEmpty = value === '' && currentVal && angular.isDefined(iAttrs.uiMaskPlaceholderChar) && iAttrs.uiMaskPlaceholderChar === 'space'; |
| 474 | + if(isTemporarilyEmpty) { |
| 475 | + iElement.val(''); |
| 476 | + } |
467 | 477 | triggerChangeEvent(iElement[0]);
|
| 478 | + if(isTemporarilyEmpty) { |
| 479 | + iElement.val(currentVal); |
| 480 | + } |
468 | 481 | }
|
469 | 482 | prevValue = value;
|
470 | 483 | }
|
@@ -603,7 +616,7 @@ angular.module('ui.mask', [])
|
603 | 616 |
|
604 | 617 | // If value has not changed, don't want to call $setViewValue, may be caused by IE raising input event due to placeholder
|
605 | 618 | if (valUnmasked !== valUnmaskedOld)
|
606 |
| - valAltered = true; |
| 619 | + valAltered = true; |
607 | 620 | }
|
608 | 621 |
|
609 | 622 | // Update values
|
|
0 commit comments