This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -414,8 +414,10 @@ angular.module('ui.mask', [])
414
414
valueMasked = '' ;
415
415
iElement . val ( '' ) ;
416
416
scope . $apply ( function ( ) {
417
- //don't call $setViewValue to avoid changing $pristine state.
418
- controller . $viewValue = '' ;
417
+ //only $setViewValue when not $pristine to avoid changing $pristine state.
418
+ if ( ! controller . $pristine ) {
419
+ controller . $setViewValue ( '' ) ;
420
+ }
419
421
} ) ;
420
422
}
421
423
}
Original file line number Diff line number Diff line change @@ -687,6 +687,16 @@ describe("uiMask", function () {
687
687
expect ( input . val ( ) ) . toBe ( "" ) ;
688
688
expect ( input . attr ( "placeholder" ) ) . toBe ( "PLACEHOLDER" ) ;
689
689
} ) ;
690
+
691
+ it ( "should not preserve $invalid on blur event" , function ( ) {
692
+ var form = compileElement ( formHtml ) ;
693
+ var input = form . find ( "input" ) ;
694
+ scope . $apply ( "x = ''" ) ;
695
+ scope . $apply ( "mask = '(A) * 9'" ) ;
696
+ input . val ( "a" ) . triggerHandler ( "input" ) ;
697
+ input . triggerHandler ( "blur" ) ;
698
+ expect ( scope . test . input . $invalid ) . toBe ( false ) ;
699
+ } ) ;
690
700
} ) ;
691
701
692
702
describe ( "Configuration Provider" , function ( ) {
You can’t perform that action at this time.
0 commit comments