浏览代码

fix getmasklength

Robin Herbots 11 年之前
父节点
当前提交
e1461d73f1
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      js/jquery.inputmask.js

+ 4 - 4
js/jquery.inputmask.js

@@ -472,8 +472,7 @@
                                 tst = getTests(validatedPos, !strict)[0]; //possible mismatch TODO
                             }
                             if (ndx > 0) {
-                                getMaskSet()["buffer"] = undefined;
-                                getMaskSet()["tests"] = {}; //clear the tests cache todo optimize
+                                resetMaskSet(true);
                             }
                             if (!setValidPosition(validatedPos, $.extend({}, tst, { "input": elem }), strict, fromSetValid))
                                 rslt = false;
@@ -505,7 +504,7 @@
             }
             function getMaskLength() {
                 var maskLength; maxLength = $el.prop('maxLength');
-                if (opts.greedy == false) {
+                if (opts.greedy == false) { //TODO FIXME OPTIMIZE ME
                     var lvp = getLastValidPosition() + 1,
                        test = getTest(lvp);
                     while (!(test.fn == null && test.def == "")) { //determine last possible position
@@ -516,6 +515,7 @@
                         }
                     }
                     maskLength = getMaskTemplate(true, lvp).length;
+                    getMaskSet()["tests"] = {}; //cleanup tests
                 } else
                     maskLength = getBuffer().length;
 
@@ -914,7 +914,7 @@
                                 p = valResult.pos != undefined ? valResult.pos : p; //set new position from isValid
                                 c = valResult.c != undefined ? valResult.c : c; //set new char from isValid
                             }
-                            getMaskSet()["buffer"] = undefined;
+                            resetMaskSet(true);
                             forwardPosition = seekNext(p);
                             getMaskSet()["p"] = forwardPosition; //needed for checkval
                         }