ソースを参照

Element keeps the focus to itself in ie11

Fixed issue where in ie11 when setting a value to the input field this was taking focus, this was addressed by updating the selection end and start only when the element is the current element in focus.
Isaac Mercieca 7 年 前
コミット
d042709f49
1 ファイル変更5 行追加3 行削除
  1. 5 3
      js/inputmask.js

+ 5 - 3
js/inputmask.js

@@ -2542,8 +2542,10 @@
 
 
                         input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
                         input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
                         if ("selectionStart" in input) {
                         if ("selectionStart" in input) {
-                            input.selectionStart = begin;
-                            input.selectionEnd = end;
+                            if (input === document.activeElement) {
+                              input.selectionStart = begin;
+                              input.selectionEnd = end;
+                            }
                         } else if (window.getSelection) {
                         } else if (window.getSelection) {
                             range = document.createRange();
                             range = document.createRange();
                             if (input.firstChild === undefined || input.firstChild === null) {
                             if (input.firstChild === undefined || input.firstChild === null) {
@@ -3204,4 +3206,4 @@
         return Inputmask;
         return Inputmask;
     }
     }
 ))
 ))
-;
+;