1
1
/*!
2
2
* angular-ui-mask
3
3
* https://github.com/angular-ui/ui-mask
4
- * Version: 1.8.6 - 2016-06-20T21:05:48.730Z
4
+ * Version: 1.8.7 - 2016-07-26T15:59:07.992Z
5
5
* License: MIT
6
6
*/
7
7
@@ -470,7 +470,7 @@ angular.module('ui.mask', [])
470
470
// Angular uses html element and calls setViewValue(element.value.trim()), setting it to the trimmed mask
471
471
// when it should be empty
472
472
var currentVal = iElement . val ( ) ;
473
- var isTemporarilyEmpty = value === '' && currentVal && angular . isDefined ( iAttrs . uiMaskPlaceholderChar ) && iAttrs . uiMaskPlaceholderChar === 'space' ;
473
+ var isTemporarilyEmpty = value === '' && currentVal && angular . isDefined ( iAttrs . uiMaskPlaceholderChar ) && iAttrs . uiMaskPlaceholderChar === 'space' ;
474
474
if ( isTemporarilyEmpty ) {
475
475
iElement . val ( '' ) ;
476
476
}
@@ -486,12 +486,20 @@ angular.module('ui.mask', [])
486
486
var change ;
487
487
if ( angular . isFunction ( window . Event ) && ! element . fireEvent ) {
488
488
// modern browsers and Edge
489
- change = new Event ( 'change' , {
490
- view : window ,
491
- bubbles : true ,
492
- cancelable : false
493
- } ) ;
494
- element . dispatchEvent ( change ) ;
489
+ try {
490
+ change = new Event ( 'change' , {
491
+ view : window ,
492
+ bubbles : true ,
493
+ cancelable : false
494
+ } ) ;
495
+ } catch ( ex ) {
496
+ //this is for certain mobile browsers that have the Event object
497
+ //but don't support the Event constructor #168
498
+ change = document . createEvent ( 'HTMLEvents' ) ;
499
+ change . initEvent ( 'change' , false , true ) ;
500
+ } finally {
501
+ element . dispatchEvent ( change ) ;
502
+ }
495
503
} else if ( 'createEvent' in document ) {
496
504
// older browsers
497
505
change = document . createEvent ( 'HTMLEvents' ) ;
@@ -523,7 +531,8 @@ angular.module('ui.mask', [])
523
531
function keydownHandler ( e ) {
524
532
/*jshint validthis: true */
525
533
var isKeyBackspace = e . which === 8 ,
526
- caretPos = getCaretPosition ( this ) - 1 || 0 ; //value in keydown is pre change so bump caret position back to simulate post change
534
+ caretPos = getCaretPosition ( this ) - 1 || 0 , //value in keydown is pre change so bump caret position back to simulate post change
535
+ isCtrlZ = e . which === 90 && e . ctrlKey ; //ctrl+z pressed
527
536
528
537
if ( isKeyBackspace ) {
529
538
while ( caretPos >= 0 ) {
@@ -537,6 +546,12 @@ angular.module('ui.mask', [])
537
546
}
538
547
preventBackspace = caretPos === - 1 ;
539
548
}
549
+
550
+ if ( isCtrlZ ) {
551
+ // prevent IE bug - value should be returned to initial state
552
+ iElement . val ( '' ) ;
553
+ e . preventDefault ( ) ;
554
+ }
540
555
}
541
556
542
557
function eventHandler ( e ) {
0 commit comments