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 @@ -410,8 +410,10 @@ angular.module('ui.mask', [])
410
410
valueMasked = '' ;
411
411
iElement . val ( '' ) ;
412
412
scope . $apply ( function ( ) {
413
- //don't call $setViewValue to avoid changing $pristine state.
414
- controller . $viewValue = '' ;
413
+ //only $setViewValue when not $pristine to avoid changing $pristine state.
414
+ if ( ! controller . $pristine ) {
415
+ controller . $setViewValue ( '' ) ;
416
+ }
415
417
} ) ;
416
418
}
417
419
}
Original file line number Diff line number Diff line change @@ -676,6 +676,16 @@ describe("uiMask", function () {
676
676
expect ( input . val ( ) ) . toBe ( "" ) ;
677
677
expect ( input . attr ( "placeholder" ) ) . toBe ( "PLACEHOLDER" ) ;
678
678
} ) ;
679
+
680
+ it ( "should not preserve $invalid on blur event" , function ( ) {
681
+ var form = compileElement ( formHtml ) ;
682
+ var input = form . find ( "input" ) ;
683
+ scope . $apply ( "x = ''" ) ;
684
+ scope . $apply ( "mask = '(A) * 9'" ) ;
685
+ input . val ( "a" ) . triggerHandler ( "input" ) ;
686
+ input . triggerHandler ( "blur" ) ;
687
+ expect ( scope . test . input . $invalid ) . toBe ( false ) ;
688
+ } ) ;
679
689
} ) ;
680
690
681
691
describe ( "Configuration Provider" , function ( ) {
You can’t perform that action at this time.
0 commit comments