@@ -437,11 +437,13 @@ angular.module('ui.mask', [])
437
437
if ( input . selectionStart !== undefined ) {
438
438
return input . selectionStart ;
439
439
} else if ( document . selection ) {
440
- // Curse you IE
441
- input . focus ( ) ;
442
- var selection = document . selection . createRange ( ) ;
443
- selection . moveStart ( 'character' , input . value ? - input . value . length : 0 ) ;
444
- return selection . text . length ;
440
+ if ( iElement . is ( ':focus' ) ) {
441
+ // Curse you IE
442
+ input . focus ( ) ;
443
+ var selection = document . selection . createRange ( ) ;
444
+ selection . moveStart ( 'character' , input . value ? - input . value . length : 0 ) ;
445
+ return selection . text . length ;
446
+ }
445
447
}
446
448
return 0 ;
447
449
}
@@ -452,16 +454,18 @@ angular.module('ui.mask', [])
452
454
return ; // Input's hidden
453
455
}
454
456
if ( input . setSelectionRange ) {
455
- input . focus ( ) ;
456
- input . setSelectionRange ( pos , pos ) ;
457
+ if ( iElement . is ( ':focus' ) ) {
458
+ input . focus ( ) ;
459
+ input . setSelectionRange ( pos , pos ) ;
460
+ }
457
461
}
458
462
else if ( input . createTextRange ) {
459
- // Curse you IE
460
- var range = input . createTextRange ( ) ;
461
- range . collapse ( true ) ;
462
- range . moveEnd ( 'character' , pos ) ;
463
- range . moveStart ( 'character' , pos ) ;
464
- range . select ( ) ;
463
+ // Curse you IE
464
+ var range = input . createTextRange ( ) ;
465
+ range . collapse ( true ) ;
466
+ range . moveEnd ( 'character' , pos ) ;
467
+ range . moveStart ( 'character' , pos ) ;
468
+ range . select ( ) ;
465
469
}
466
470
}
467
471
0 commit comments