Browse Source

update alteration logic

Robin Herbots 10 years ago
parent
commit
c93849e06a

+ 1 - 1
.eslintrc

@@ -17,7 +17,7 @@
       1,
       "except-parens"
     ],
-    "new-cap": [1],
+    "new-cap": [0],
     "no-empty": [0],
     "no-loop-func": [0],
     "no-underscore-dangle": [0],

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
 ### Added
 
 ### Updates
+- allow passing an element id to the mask function
 - allow passing a selector to the mask function
 - fix for bower package
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.4-17",
+  "version": "3.2.4-35",
   "main": [
     "./dist/inputmask/inputmask.js"
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.2.4-17",
+  "version": "3.2.4-35",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.2.4-17",
+  "version": "3.2.4-35",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 44 - 38
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -337,6 +337,13 @@
         function getTests(pos, ndxIntlzr, tstPs, cacheable) {
             function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
                 function handleMatch(match, loopNdx, quantifierRecurse) {
+                    function resolveNdxInitializer(pos, alternateNdx) {
+                        var previousMatch = getMaskSet().validPositions[pos];
+                        return void 0 === previousMatch && getMaskSet().tests[pos] && $.each(getMaskSet().tests[pos], function(ndx, lmnt) {
+                            return lmnt.alternation && -1 !== lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) ? (previousMatch = lmnt, 
+                            !1) : void 0;
+                        }), previousMatch ? previousMatch.locator.slice(previousMatch.alternation + 1) : [];
+                    }
                     if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
                     if (testPos === pos && void 0 === match.matches) return matches.push({
                         match: match,
@@ -355,10 +362,11 @@
                         } else if (match.isAlternator) {
                             var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
                             if (-1 === altIndex || "string" == typeof altIndex) {
-                                var currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
-                                "string" == typeof altIndex && (altIndexArr = altIndex.split(","));
-                                for (var amndx = 0; amndx < alternateToken.matches.length; amndx++) {
-                                    if (matches = [], match = handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
+                                var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
+                                if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
+                                for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
+                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx), 
+                                    match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
                                     match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
                                         var ntndx = maskToken.matches.indexOf(match) + 1;
                                         maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse), 
@@ -374,9 +382,9 @@
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                             var altMatch2 = malternateMatches[ndx2];
                                             if (altMatch.match.def === altMatch2.match.def && ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr))) {
-                                                altMatch.match.mask === altMatch2.match.mask ? (maltMatches.splice(ndx1, 1), ndx1--) : altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                altMatch2.alternation = altMatch.alternation;
+                                                altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--), 
+                                                -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
+                                                altMatch2.alternation = altMatch.alternation);
                                                 break;
                                             }
                                         }
@@ -394,7 +402,7 @@
                                         if (void 0 !== lmnt.locator[alternation]) return lmnt;
                                     }
                                 })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
-                            } else match = alternateToken.matches[altIndex] ? handleMatch(alternateToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse) : !1;
+                            } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;
                         } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
                             var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
@@ -419,26 +427,27 @@
                 }
             }
             var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
-            if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
-            if (void 0 === ndxIntlzr) {
-                for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
-                void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
-            }
-            for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
-                var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
-                if (match && testPos === pos || testPos > pos) break;
+            if (pos > -1) {
+                if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
+                if (void 0 === ndxIntlzr) {
+                    for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
+                    void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
+                }
+                for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
+                    var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
+                    if (match && testPos === pos || testPos > pos) break;
+                }
+                return (0 === matches.length || insertStop) && matches.push({
+                    match: {
+                        fn: null,
+                        cardinality: 0,
+                        optionality: !0,
+                        casing: null,
+                        def: ""
+                    },
+                    locator: []
+                }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
             }
-            return (0 === matches.length || insertStop) && matches.push({
-                match: {
-                    fn: null,
-                    cardinality: 0,
-                    optionality: !0,
-                    casing: null,
-                    def: ""
-                },
-                locator: []
-            }), getMaskSet().tests[pos] = $.extend(!0, [], matches), console.log(pos + " - " + JSON.stringify(matches)), 
-            getMaskSet().tests[pos];
         }
         function getBufferTemplate() {
             return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)), 
@@ -519,7 +528,7 @@
                     lastAlt = parseInt(lastAlt);
                     for (var decisionPos in getMaskSet().validPositions) if (decisionPos = parseInt(decisionPos), 
                     altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
-                        var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = altPos.locator[alternation] || altNdxs[0];
+                        var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
                         decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
                             for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp], 
@@ -530,7 +539,7 @@
                             if (decisionTaker !== possibilityPos.locator[alternation]) {
                                 var validInputs = [], staticInputsBeforePos = 0;
                                 for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                validPos && (null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++), 
+                                validPos && null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++, 
                                 delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
                                 for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
                                     var input = validInputs.shift();
@@ -540,7 +549,7 @@
                                 isValidRslt) {
                                     var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0;
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                    validPos && null == validPos.match.fn && pos > i && staticInputsBeforePosAlternate++;
+                                    (void 0 === validPos || null == validPos.match.fn) && pos > i && staticInputsBeforePosAlternate++;
                                     pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
                                 }
                                 if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
@@ -600,11 +609,8 @@
             var test = getTest(pos);
             if (null != test.fn) return test.fn;
             if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
-                for (var tests = getTests(pos), staticAlternations = !0, i = 0; i < tests.length; i++) if ("" !== tests[i].match.def && (void 0 === tests[i].alternation || tests[i].locator[tests[i].alternation].length > 1)) {
-                    staticAlternations = !1;
-                    break;
-                }
-                return staticAlternations;
+                var tests = getTests(pos, void 0, void 0, !0);
+                return tests.length > 2;
             }
             return !1;
         }
@@ -1263,8 +1269,8 @@
         masksCache: {},
         mask: function(elems) {
             var that = this;
-            return "string" == typeof elems && (elems = document.querySelectorAll(elems)), elems = elems.nodeName ? [ elems ] : elems, 
-            $.each(elems, function(ndx, el) {
+            return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), 
+            elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
                 var scopedOpts = $.extend(!0, {}, that.opts);
                 importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
                 var maskset = generateMaskSet(scopedOpts, that.noMasksCache);

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 44 - 38
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -335,6 +335,13 @@
         function getTests(pos, ndxIntlzr, tstPs, cacheable) {
             function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
                 function handleMatch(match, loopNdx, quantifierRecurse) {
+                    function resolveNdxInitializer(pos, alternateNdx) {
+                        var previousMatch = getMaskSet().validPositions[pos];
+                        return void 0 === previousMatch && getMaskSet().tests[pos] && $.each(getMaskSet().tests[pos], function(ndx, lmnt) {
+                            return lmnt.alternation && -1 !== lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) ? (previousMatch = lmnt, 
+                            !1) : void 0;
+                        }), previousMatch ? previousMatch.locator.slice(previousMatch.alternation + 1) : [];
+                    }
                     if (testPos > 1e4) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
                     if (testPos === pos && void 0 === match.matches) return matches.push({
                         match: match,
@@ -353,10 +360,11 @@
                         } else if (match.isAlternator) {
                             var maltMatches, alternateToken = match, malternateMatches = [], currentMatches = matches.slice(), loopNdxCnt = loopNdx.length, altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
                             if (-1 === altIndex || "string" == typeof altIndex) {
-                                var currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
-                                "string" == typeof altIndex && (altIndexArr = altIndex.split(","));
-                                for (var amndx = 0; amndx < alternateToken.matches.length; amndx++) {
-                                    if (matches = [], match = handleMatch(alternateToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
+                                var amndx, currentPos = testPos, ndxInitializerClone = ndxInitializer.slice(), altIndexArr = [];
+                                if ("string" == typeof altIndex) altIndexArr = altIndex.split(","); else for (amndx = 0; amndx < alternateToken.matches.length; amndx++) altIndexArr.push(amndx);
+                                for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
+                                    if (amndx = parseInt(altIndexArr[ndx]), matches = [], ndxInitializer = resolveNdxInitializer(testPos, amndx), 
+                                    match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [ amndx ].concat(loopNdx), quantifierRecurse) || match, 
                                     match !== !0 && void 0 !== match && altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length) {
                                         var ntndx = maskToken.matches.indexOf(match) + 1;
                                         maskToken.matches.length > ntndx && (match = handleMatch(maskToken.matches[ntndx], [ ntndx ].concat(loopNdx.slice(1, loopNdx.length)), quantifierRecurse), 
@@ -372,9 +380,9 @@
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                             var altMatch2 = malternateMatches[ndx2];
                                             if (altMatch.match.def === altMatch2.match.def && ("string" != typeof altIndex || -1 !== $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr))) {
-                                                altMatch.match.mask === altMatch2.match.mask ? (maltMatches.splice(ndx1, 1), ndx1--) : altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                altMatch2.alternation = altMatch.alternation;
+                                                altMatch.match.mask === altMatch2.match.mask && (maltMatches.splice(ndx1, 1), ndx1--), 
+                                                -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
+                                                altMatch2.alternation = altMatch.alternation);
                                                 break;
                                             }
                                         }
@@ -392,7 +400,7 @@
                                         if (void 0 !== lmnt.locator[alternation]) return lmnt;
                                     }
                                 })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0;
-                            } else match = alternateToken.matches[altIndex] ? handleMatch(alternateToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse) : !1;
+                            } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;
                         } else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) for (var qt = match, qndx = ndxInitializer.length > 0 ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) && pos >= testPos; qndx++) {
                             var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
@@ -417,26 +425,27 @@
                 }
             }
             var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
-            if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
-            if (void 0 === ndxIntlzr) {
-                for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
-                void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
-            }
-            for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
-                var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
-                if (match && testPos === pos || testPos > pos) break;
+            if (pos > -1) {
+                if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
+                if (void 0 === ndxIntlzr) {
+                    for (var test, previousPos = pos - 1; void 0 === (test = getMaskSet().validPositions[previousPos]) && previousPos > -1 && (!getMaskSet().tests[previousPos] || void 0 === (test = getMaskSet().tests[previousPos][0])); ) previousPos--;
+                    void 0 !== test && previousPos > -1 && (testPos = previousPos, ndxInitializer = test.locator.slice());
+                }
+                for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
+                    var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [ mtndx ]);
+                    if (match && testPos === pos || testPos > pos) break;
+                }
+                return (0 === matches.length || insertStop) && matches.push({
+                    match: {
+                        fn: null,
+                        cardinality: 0,
+                        optionality: !0,
+                        casing: null,
+                        def: ""
+                    },
+                    locator: []
+                }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
             }
-            return (0 === matches.length || insertStop) && matches.push({
-                match: {
-                    fn: null,
-                    cardinality: 0,
-                    optionality: !0,
-                    casing: null,
-                    def: ""
-                },
-                locator: []
-            }), getMaskSet().tests[pos] = $.extend(!0, [], matches), console.log(pos + " - " + JSON.stringify(matches)), 
-            getMaskSet().tests[pos];
         }
         function getBufferTemplate() {
             return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)), 
@@ -517,7 +526,7 @@
                     lastAlt = parseInt(lastAlt);
                     for (var decisionPos in getMaskSet().validPositions) if (decisionPos = parseInt(decisionPos), 
                     altPos = getMaskSet().validPositions[decisionPos], decisionPos >= lastAlt && void 0 !== altPos.alternation) {
-                        var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = altPos.locator[alternation] || altNdxs[0];
+                        var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","), decisionTaker = void 0 !== altPos.locator[alternation] ? altPos.locator[alternation] : altNdxs[0];
                         decisionTaker.length > 0 && (decisionTaker = decisionTaker.split(",")[0]);
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) if (decisionTaker < altNdxs[mndx]) {
                             for (var possibilityPos, possibilities, dp = decisionPos; dp >= 0; dp--) if (possibilityPos = getMaskSet().validPositions[dp], 
@@ -528,7 +537,7 @@
                             if (decisionTaker !== possibilityPos.locator[alternation]) {
                                 var validInputs = [], staticInputsBeforePos = 0;
                                 for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                validPos && (null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++), 
+                                validPos && null != validPos.match.fn ? validInputs.push(validPos.input) : pos > i && staticInputsBeforePos++, 
                                 delete getMaskSet().validPositions[i], delete getMaskSet().tests[i];
                                 for (resetMaskSet(!0), opts.keepStatic = !opts.keepStatic, isValidRslt = !0; validInputs.length > 0; ) {
                                     var input = validInputs.shift();
@@ -538,7 +547,7 @@
                                 isValidRslt) {
                                     var targetLvp = getLastValidPosition(pos) + 1, staticInputsBeforePosAlternate = 0;
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                    validPos && null == validPos.match.fn && pos > i && staticInputsBeforePosAlternate++;
+                                    (void 0 === validPos || null == validPos.match.fn) && pos > i && staticInputsBeforePosAlternate++;
                                     pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid);
                                 }
                                 if (opts.keepStatic = !opts.keepStatic, isValidRslt) return isValidRslt;
@@ -598,11 +607,8 @@
             var test = getTest(pos);
             if (null != test.fn) return test.fn;
             if (pos > -1 && !opts.keepStatic && void 0 === getMaskSet().validPositions[pos]) {
-                for (var tests = getTests(pos), staticAlternations = !0, i = 0; i < tests.length; i++) if ("" !== tests[i].match.def && (void 0 === tests[i].alternation || tests[i].locator[tests[i].alternation].length > 1)) {
-                    staticAlternations = !1;
-                    break;
-                }
-                return staticAlternations;
+                var tests = getTests(pos, void 0, void 0, !0);
+                return tests.length > 2;
             }
             return !1;
         }
@@ -1261,8 +1267,8 @@
         masksCache: {},
         mask: function(elems) {
             var that = this;
-            return "string" == typeof elems && (elems = document.querySelectorAll(elems)), elems = elems.nodeName ? [ elems ] : elems, 
-            $.each(elems, function(ndx, el) {
+            return "string" == typeof elems && (elems = document.getElementById(elems) || document.querySelectorAll(elems)), 
+            elems = elems.nodeName ? [ elems ] : elems, $.each(elems, function(ndx, el) {
                 var scopedOpts = $.extend(!0, {}, that.opts);
                 importAttributeOptions(el, scopedOpts, $.extend(!0, {}, that.userOptions));
                 var maskset = generateMaskSet(scopedOpts, that.noMasksCache);

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.jquery.min.js

@@ -3,6 +3,6 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.4-17
+* Version: 3.2.4-35
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


File diff suppressed because it is too large
+ 3 - 3
dist/min/inputmask/inputmask.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


File diff suppressed because it is too large
+ 4 - 4
dist/min/jquery.inputmask.bundle.min.js


+ 82 - 68
js/inputmask.js

@@ -120,7 +120,7 @@
 			mask: function(elems) {
 				var that = this;
 				if (typeof elems === "string") {
-					elems = document.querySelectorAll(elems);
+					elems = document.getElementById(elems) || document.querySelectorAll(elems);
 				}
 				elems = elems.nodeName ? [elems] : elems;
 				$.each(elems, function(ndx, el) {
@@ -948,8 +948,22 @@
 					insertStop = false,
 					latestMatch, isFirstMatch;
 
-				function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitilizer contains a set of indexes to speedup searches in the mtokens
+				function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitializer contains a set of indexes to speedup searches in the mtokens
 					function handleMatch(match, loopNdx, quantifierRecurse) {
+						function resolveNdxInitializer(pos, alternateNdx) {
+							var previousMatch = getMaskSet().validPositions[pos];
+							if (previousMatch === undefined) {
+								if (getMaskSet().tests[pos]) {
+									$.each(getMaskSet().tests[pos], function(ndx, lmnt) {
+										if (lmnt.alternation && lmnt.locator[lmnt.alternation].toString().indexOf(alternateNdx) !== -1) {
+											previousMatch = lmnt;
+											return false;
+										}
+									});
+								}
+							}
+							return previousMatch ? previousMatch.locator.slice(previousMatch.alternation + 1) : [];
+						}
 						if (testPos > 10000) {
 							throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + getMaskSet().mask;
 						}
@@ -984,11 +998,21 @@
 								if (altIndex === -1 || typeof altIndex === "string") {
 									var currentPos = testPos,
 										ndxInitializerClone = ndxInitializer.slice(),
-										altIndexArr = [];
-									if (typeof altIndex == "string") altIndexArr = altIndex.split(",");
-									for (var amndx = 0; amndx < alternateToken.matches.length; amndx++) {
+										altIndexArr = [],
+										amndx;
+									if (typeof altIndex == "string") {
+										altIndexArr = altIndex.split(",");
+									} else {
+										for (amndx = 0; amndx < alternateToken.matches.length; amndx++) {
+											altIndexArr.push(amndx);
+										}
+									}
+									for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
+										amndx = parseInt(altIndexArr[ndx]);
 										matches = [];
-										match = handleMatch(alternateToken.matches[amndx], [amndx].concat(loopNdx), quantifierRecurse) || match;
+										//set the correct ndxInitializer
+										ndxInitializer = resolveNdxInitializer(testPos, amndx);
+										match = handleMatch(alternateToken.matches[amndx] || maskToken.matches[amndx], [amndx].concat(loopNdx), quantifierRecurse) || match;
 										if (match !== true && match !== undefined && (altIndexArr[altIndexArr.length - 1] < alternateToken.matches.length)) { //no match in the alternations (length mismatch) => look further
 											var ntndx = maskToken.matches.indexOf(match) + 1;
 											if (maskToken.matches.length > ntndx) {
@@ -1019,11 +1043,11 @@
 													if (altMatch.match.mask === altMatch2.match.mask) {
 														maltMatches.splice(ndx1, 1);
 														ndx1--;
-													} else {
-														altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation];
 													}
-													altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation];
-													altMatch2.alternation = altMatch.alternation; //we pass the alternation index => used in determineLastRequiredPosition
+													if (altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1) {
+														altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation];
+														altMatch2.alternation = altMatch.alternation; //we pass the alternation index => used in determineLastRequiredPosition
+													}
 													break;
 												}
 											}
@@ -1057,11 +1081,11 @@
 
 									matches = currentMatches.concat(malternateMatches);
 									testPos = pos;
-									insertStop = matches.length > 0; //insert a stopelemnt when there is an alternate
+									insertStop = matches.length > 0; //insert a stopelemnt when there is an alternate - needed for non-greedy option
 								} else {
-									if (alternateToken.matches[altIndex]) { //if not in the initial alternation => look further
-										match = handleMatch(alternateToken.matches[altIndex], [altIndex].concat(loopNdx), quantifierRecurse);
-									} else match = false;
+									// if (alternateToken.matches[altIndex]) { //if not in the initial alternation => look further
+									match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [altIndex].concat(loopNdx), quantifierRecurse);
+									// } else match = false;
 								}
 								if (match) return true;
 							} else if (match.isQuantifier && quantifierRecurse !== maskToken.matches[$.inArray(match, maskToken.matches) - 1]) {
@@ -1106,46 +1130,47 @@
 					}
 				}
 
-				if (cacheable === true && getMaskSet().tests[pos]) {
-					return getMaskSet().tests[pos];
-				}
-				if (ndxIntlzr === undefined) {
-					var previousPos = pos - 1,
-						test;
-					while ((test = getMaskSet().validPositions[previousPos]) === undefined && previousPos > -1) {
-						if (getMaskSet().tests[previousPos] && (test = getMaskSet().tests[previousPos][0]) !== undefined) {
-							break;
-						}
-						previousPos--;
+				if (pos > -1) {
+					if (cacheable === true && getMaskSet().tests[pos]) {
+						return getMaskSet().tests[pos];
+					}
+					if (ndxIntlzr === undefined) {
+						var previousPos = pos - 1,
+							test;
+						while ((test = getMaskSet().validPositions[previousPos]) === undefined && previousPos > -1) {
+							if (getMaskSet().tests[previousPos] && (test = getMaskSet().tests[previousPos][0]) !== undefined) {
+								break;
+							}
+							previousPos--;
 
+						}
+						if (test !== undefined && previousPos > -1) {
+							testPos = previousPos;
+							ndxInitializer = test.locator.slice();
+						}
 					}
-					if (test !== undefined && previousPos > -1) {
-						testPos = previousPos;
-						ndxInitializer = test.locator.slice();
+					for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
+						var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [mtndx]);
+						if ((match && testPos === pos) || testPos > pos) {
+							break;
+						}
 					}
-				}
-				for (var mtndx = ndxInitializer.shift(); mtndx < maskTokens.length; mtndx++) {
-					var match = resolveTestFromToken(maskTokens[mtndx], ndxInitializer, [mtndx]);
-					if ((match && testPos === pos) || testPos > pos) {
-						break;
+					if (matches.length === 0 || insertStop) {
+						matches.push({
+							"match": {
+								fn: null,
+								cardinality: 0,
+								optionality: true,
+								casing: null,
+								def: ""
+							},
+							"locator": []
+						});
 					}
+					getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
+					// console.log(pos + " - " + JSON.stringify(matches));
+					return getMaskSet().tests[pos];
 				}
-				if (matches.length === 0 || insertStop) {
-					matches.push({
-						"match": {
-							fn: null,
-							cardinality: 0,
-							optionality: true,
-							casing: null,
-							def: ""
-						},
-						"locator": []
-					});
-				}
-				getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
-
-				console.log(pos + " - " + JSON.stringify(matches));
-				return getMaskSet().tests[pos];
 			}
 
 			function getBufferTemplate() {
@@ -1328,7 +1353,7 @@
 							altPos = getMaskSet().validPositions[decisionPos];
 							if (decisionPos >= lastAlt && altPos.alternation !== undefined) {
 								var altNdxs = getMaskSet().validPositions[lastAlt].locator[alternation].toString().split(","),
-									decisionTaker = altPos.locator[alternation] || altNdxs[0]; //no match in the alternations (length mismatch)
+									decisionTaker = altPos.locator[alternation] !== undefined ? altPos.locator[alternation] : altNdxs[0]; //no match in the alternations (length mismatch)
 								if (decisionTaker.length > 0) { //no decision taken ~ take first one as decider
 									decisionTaker = decisionTaker.split(",")[0];
 								}
@@ -1350,11 +1375,9 @@
 												staticInputsBeforePos = 0;
 											for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
 												validPos = getMaskSet().validPositions[i];
-												if (validPos) {
-													if (validPos.match.fn != null) {
-														validInputs.push(validPos.input);
-													} else if (i < pos) staticInputsBeforePos++;
-												}
+												if (validPos && validPos.match.fn != null) {
+													validInputs.push(validPos.input);
+												} else if (i < pos) staticInputsBeforePos++;
 												delete getMaskSet().validPositions[i];
 												delete getMaskSet().tests[i];
 											}
@@ -1377,7 +1400,7 @@
 												var staticInputsBeforePosAlternate = 0;
 												for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
 													validPos = getMaskSet().validPositions[i];
-													if (validPos && validPos.match.fn == null && i < pos) {
+													if ((validPos === undefined || validPos.match.fn == null) && i < pos) {
 														staticInputsBeforePosAlternate++;
 													}
 												}
@@ -1501,17 +1524,9 @@
 				if (test.fn != null) {
 					return test.fn;
 				} else if (pos > -1 && !opts.keepStatic && getMaskSet().validPositions[pos] === undefined) {
-					var tests = getTests(pos),
-						staticAlternations = true;
-					for (var i = 0; i < tests.length; i++) {
-						if (tests[i].match.def !== "" && ( /*tests[i].match.fn !== null || */ (tests[i].alternation === undefined || tests[i].locator[tests[i].alternation].length > 1))) {
-							staticAlternations = false;
-							break;
-						}
-					}
-					return staticAlternations;
+					var tests = getTests(pos, undefined, undefined, true);
+					return tests.length > 2;
 				}
-
 				return false;
 			}
 
@@ -1601,9 +1616,8 @@
 						}
 					}
 					return test.def;
-				} else {
-					return opts.placeholder.charAt(pos % opts.placeholder.length);
 				}
+				return opts.placeholder.charAt(pos % opts.placeholder.length);
 			}
 
 			function checkVal(input, writeOut, strict, nptvl) {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.4-17",
+  "version": "3.2.4-35",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [

+ 2 - 2
qunit/config.js

@@ -7,7 +7,7 @@ require.config({
 		"inputmask.dependencyLib": "../dist/inputmask/inputmask.dependencyLib.jquery",
 		// "inputmask.dependencyLib": "../extra/dependencyLibs/inputmask.dependencyLib",
 		// "inputmask.dependencyLib": "../extra/dependencyLibs/inputmask.dependencyLib.jqlite",
-		"inputmask": "../dist/inputmask/inputmask"
-		// "inputmask": "../js/inputmask"
+		// "inputmask": "../dist/inputmask/inputmask"
+		"inputmask": "../js/inputmask"
 	}
 });

File diff suppressed because it is too large
+ 528 - 510
qunit/tests_base.js


+ 282 - 195
qunit/tests_keepStatic.js

@@ -11,209 +11,296 @@ define([
 	"simulator"
 ], function(qunit, $, Inputmask) {
 
-qunit.module("keepStatic mask switching");
+	qunit.module("keepStatic mask switching");
+
+	qunit.test("{ mask: [\"+55-99-9999-9999\", \"+55-99-99999-9999\", ], keepStatic: true }", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["+55-99-9999-9999", "+55-99-99999-9999"],
+			keepStatic: true
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123451234");
+
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("{ mask: \"+55-99-9999|(99)-9999\", keepStatic: true } - type 12123451234", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: "+55-99-9999|(99)-9999",
+			keepStatic: true
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123451234");
+
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("{ mask: ['(99) 9999-9999', '(99) 99999-9999'] } - val('1212341234')", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ['(99) 9999-9999', '(99) 99999-9999']
+		}).mask(testmask);
+		$("#testmask").val("1212341234");
+
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1234-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
 
-test("{ mask: [\"+55-99-9999-9999\", \"+55-99-99999-9999\", ], keepStatic: true }", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: ["+55-99-9999-9999", "+55-99-99999-9999"], keepStatic: true }).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123451234");
+	});
+
+	qunit.test("{ mask: \"+55-99-9999|(99)-9999\", keepStatic: false } type 12123451234", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: "+55-99-9999|(99)-9999",
+			keepStatic: false
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123451234");
 
-    equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("{ mask: [\"+55-99-9999-9999\", \"+55-99-99999-9999\", ], keepStatic: true } - type 12123451234 + backspace", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["+55-99-9999-9999", "+55-99-99999-9999"],
+			keepStatic: true
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123451234");
+		$("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
+
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-1234-5123", "Result " + document.getElementById("testmask").inputmask._valueGet());
 
-    $("#testmask").remove();
-});
-
-test("{ mask: \"+55-99-9999|(99)-9999\", keepStatic: true } - type 12123451234", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: "+55-99-9999|(99)-9999", keepStatic: true }).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123451234");
-
-    equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("{ mask: ['(99) 9999-9999', '(99) 99999-9999'] } - val('1212341234')", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: ['(99) 9999-9999', '(99) 99999-9999'] }).mask(testmask);
-    $("#testmask").val("1212341234");
 
-    equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1234-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
 
-    $("#testmask").remove();
-});
-
-test("{ mask: \"+55-99-9999|(99)-9999\", keepStatic: false } type 12123451234", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: "+55-99-9999|(99)-9999", keepStatic: false }).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123451234");
-
-    equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-12345-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	qunit.test("{ mask: [\"99-9999-99\",\"99-99999-99\"] } - type 12123412 + add 1 upfront", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99-9999-99", "99-99999-99"]
+		}).mask(testmask);
+		$("#testmask").Type("12123412");
+		$.caret(testmask, 0);
+		$("#testmask").Type("1");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "11-21234-12", "Result " + document.getElementById("testmask").inputmask._valueGet());
 
-    $("#testmask").remove();
-});
-
-test("{ mask: [\"+55-99-9999-9999\", \"+55-99-99999-9999\", ], keepStatic: true } - type 12123451234 + backspace", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: ["+55-99-9999-9999", "+55-99-99999-9999"], keepStatic: true }).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123451234");
-    $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
 
-    equal(document.getElementById("testmask").inputmask._valueGet(), "+55-12-1234-5123", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
+
+	qunit.test("{ mask: [\"99-99999-9\",\"99-999999-9\"] } - type 121234561", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99-99999-9", "99-999999-9"]
+		}).mask(testmask);
+		$("#testmask").Type("121234561");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12-123456-1", "Result " + document.getElementById("testmask").inputmask._valueGet());
 
-    $("#testmask").remove();
-});
-
-test("{ mask: [\"99-9999-99\",\"99-99999-99\"] } - type 12123412 + add 1 upfront", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: ["99-9999-99", "99-99999-99"] }).mask(testmask);
-    $("#testmask").Type("12123412");
-    $.caret(testmask, 0);
-    $("#testmask").Type("1");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "11-21234-12", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("{ mask: [\"99-99999-9\",\"99-999999-9\"] } - type 121234561", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: ["99-99999-9", "99-999999-9"] }).mask(testmask);
-    $("#testmask").Type("121234561");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "12-123456-1", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("{ \"keepStatic\": true, greedy: false, mask: \"(99-9)|(99999)\" } - type 12345", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ "keepStatic": true, greedy: false, "mask": "(99-9)|(99999)" }).mask(testmask);
-    $("#testmask").Type("12345");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "12345", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("7|8 999 99 99 - hiddenman", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("7|8 999 99 99").mask(testmask);
-    testmask.focus();
-    equal(document.getElementById("testmask").inputmask._valueGet(), "_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
 
-test("7|8 999 99 99 type 7 - hiddenman", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("7|8 999 99 99").mask(testmask);
-    $("#testmask").Type("7");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "7 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("7|8 999 99 99 type 8 - hiddenman", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("7|8 999 99 99").mask(testmask);
-    $("#testmask").Type("8");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "8 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("(78)|(79) 999 99 99", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("(78)|(79) 999 99 99").mask(testmask);
-    testmask.focus();
-    equal(document.getElementById("testmask").inputmask._valueGet(), "7_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("(78)|(79) 999 99 99 - type 5", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("(78)|(79) 999 99 99").mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("5");
-    equal(document.getElementById("testmask").inputmask._valueGet(), "75 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("(78)|(74) 999 99 99", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask("(78)|(74) 999 99 99").mask(testmask);
-    testmask.focus();
-    equal(document.getElementById("testmask").inputmask._valueGet(), "7_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("5-9|(9a)-5 - keepstatic: false", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({ mask: "5-9|(9a)-5", keepStatic: false }).mask(testmask);
-    testmask.focus();
-    equal(document.getElementById("testmask").inputmask._valueGet(), "5-_-5", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("['(99) 9999-9999', '(99) 9-9999-9999'] - type 12123412345 - 3m0", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({mask:['(99) 9999-9999', '(99) 9-9999-9999'], removeMaskOnSubmit:false, clearmaskonlostfocus:true}).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123412345")
-    equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1-2341-2345", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
-
-test("['(99) 9999-9999', '(99) 9-9999-9999'] - type 12123412345 - backspace - 3m0", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-var testmask = document.getElementById("testmask");
-    Inputmask({mask:['(99) 9999-9999', '(99) 9-9999-9999'], removeMaskOnSubmit:false, clearmaskonlostfocus:true}).mask(testmask);
-    testmask.focus();
-    $("#testmask").Type("12123412345")
-    $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
-    equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1234-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
-
-    $("#testmask").remove();
-});
+	});
 
+	qunit.test("{ \"keepStatic\": true, greedy: false, mask: \"(99-9)|(99999)\" } - type 12345", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			"keepStatic": true,
+			greedy: false,
+			"mask": "(99-9)|(99999)"
+		}).mask(testmask);
+		$("#testmask").Type("12345");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12345", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("7|8 999 99 99 - hiddenman", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("7|8 999 99 99").mask(testmask);
+		testmask.focus();
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("7|8 999 99 99 type 7 - hiddenman", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("7|8 999 99 99").mask(testmask);
+		$("#testmask").Type("7");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "7 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("7|8 999 99 99 type 8 - hiddenman", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("7|8 999 99 99").mask(testmask);
+		$("#testmask").Type("8");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "8 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("(78)|(79) 999 99 99", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(78)|(79) 999 99 99").mask(testmask);
+		testmask.focus();
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "7_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("(78)|(79) 999 99 99 - type 5", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(78)|(79) 999 99 99").mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("5");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "75 ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("(78)|(74) 999 99 99", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(78)|(74) 999 99 99").mask(testmask);
+		testmask.focus();
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "7_ ___ __ __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("5-9|(9a)-5 - keepstatic: false", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: "5-9|(9a)-5",
+			keepStatic: false
+		}).mask(testmask);
+		testmask.focus();
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "5-_-5", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("['(99) 9999-9999', '(99) 9-9999-9999'] - type 12123412345 - 3m0", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ['(99) 9999-9999', '(99) 9-9999-9999'],
+			removeMaskOnSubmit: false,
+			clearmaskonlostfocus: true
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123412345")
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1-2341-2345", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+
+	qunit.test("['(99) 9999-9999', '(99) 9-9999-9999'] - type 12123412345 - backspace - 3m0", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ['(99) 9999-9999', '(99) 9-9999-9999'],
+			removeMaskOnSubmit: false,
+			clearmaskonlostfocus: true
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12123412345")
+		$("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "(12) 1234-1234", "Result " + document.getElementById("testmask").inputmask._valueGet());
+
+
+	});
+	qunit.test("(99 99)|(*****) keepStatic false - type 12 abc", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(99 99)|(*****)", {
+			keepStatic: false
+		}).mask(testmask);
+
+		$("#testmask").Type("12 abc");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12 __", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
+	qunit.test("(99 99)|(*****) keepStatic false - type 12 123", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(99 99)|(*****)", {
+			keepStatic: false
+		}).mask(testmask);
+
+		$("#testmask").Type("12 123");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12 12", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
+	qunit.test("(99 99)|(*****) keepStatic true - type 1212", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(99 99)|(*****)", {
+			keepStatic: true
+		}).mask(testmask);
+
+		$("#testmask").Type("1212");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12 12", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
+	qunit.test("(99 99)|(*****) keepStatic true - type 12123", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(99 99)|(*****)", {
+			keepStatic: true
+		}).mask(testmask);
+
+		$("#testmask").Type("12123");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "12123", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
+	qunit.test("(99 99)|(*****) keepStatic true - type abcde", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask("(99 99)|(*****)", {
+			keepStatic: true
+		}).mask(testmask);
+
+		$("#testmask").Type("abcde");
+		assert.equal(document.getElementById("testmask").inputmask._valueGet(), "abcde", "Result " + document.getElementById("testmask").inputmask._valueGet());
+	});
 });

+ 293 - 279
qunit/tests_multi.js

@@ -11,301 +11,315 @@ define([
 	"simulator"
 ], function(qunit, $, Inputmask) {
 
-qunit.module("multi masks");
-asyncTest("inputmask({ mask: [\"99-99\", \"999-99\"]}) - input 12345", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99-99", "999-99"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12345");
-	setTimeout(function() {
-		equal(testmask.value, "123-45", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 12312312312", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["999.999.999-99", "99.999.999/9999-99"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12312312312");
-	setTimeout(function() {
-		equal(testmask.value, "123.123.123-12", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 12.123123123412", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["999.999.999-99", "99.999.999/9999-99"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12.123123123412");
-	setTimeout(function() {
-		equal(testmask.value, "12.123.123/1234-12", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+	qunit.module("multi masks");
+	qunit.test("inputmask({ mask: [\"99-99\", \"999-99\"]}) - input 12345", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99-99", "999-99"]
+		}).mask(testmask);
 
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345 greedy + blur", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12345");
-	testmask.blur();
-	setTimeout(function() {
-		equal(testmask.value, "12345", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345 not greedy", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999"],
-		greedy: false,
-		keepStatic: true
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12345");
-	setTimeout(function() {
-		equal(testmask.value, "12345", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345-1234", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12345-1234");
-	setTimeout(function() {
-		equal(testmask.value, "12345-1234", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 123451234", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("123451234");
-	setTimeout(function() {
-		equal(testmask.value, "12345-1234", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 1234512", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("1234512");
-	setTimeout(function() {
-		equal(testmask.value, "12345-12__", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+		testmask.focus();
+		$("#testmask").Type("12345");
+		setTimeout(function() {
+			assert.equal(testmask.value, "123-45", "Result " + testmask.value);
+			done();
 
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 1234561234", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999", "999999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("1234561234");
-	setTimeout(function() {
-		equal(testmask.value, "123456-1234", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 12312312312", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["999.999.999-99", "99.999.999/9999-99"]
+		}).mask(testmask);
 
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 12345-6", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999", "999999-9999"]
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("12345-6");
-	setTimeout(function() {
-		equal(testmask.value, "12345-6___", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"], keepStatic: false}) - input 123456", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999", "999999-9999"],
-		keepStatic: false
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("123456");
-	setTimeout(function() {
-		equal(testmask.value, "123456-____", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+		testmask.focus();
+		$("#testmask").Type("12312312312");
+		setTimeout(function() {
+			assert.equal(testmask.value, "123.123.123-12", "Result " + testmask.value);
+			done();
 
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"] , keepStatic: true}) - input 123456", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999", "999999-9999"],
-		keepStatic: true
-	}).mask(testmask);
-
-	testmask.focus();
-	$("#testmask").Type("123456");
-	setTimeout(function() {
-		equal(testmask.value, "12345-6___", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"999.999.999-99\", \"99.999.999/9999-99\"]}) - input 12.123123123412", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["999.999.999-99", "99.999.999/9999-99"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("12.123123123412");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12.123.123/1234-12", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345 greedy + blur", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("12345");
+		testmask.blur();
+		setTimeout(function() {
+			assert.equal(testmask.inputmask._valueGet(), "12345", "Result " + testmask.inputmask._valueGet());
+			done();
+
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345 not greedy", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999"],
+			greedy: false,
+			keepStatic: true
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("12345");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 12345-1234", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999"]
+		}).mask(testmask);
 
-asyncTest("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 123456 (rtl)", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" dir="rtl" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99999", "99999-9999", "999999-9999"]
-	}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("12345-1234");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345-1234", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 123451234", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("123451234");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345-1234", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\"]]}) - input 1234512", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("1234512");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345-12__", "Result " + testmask.value);
+			done();
 
-	testmask.focus();
-	setTimeout(function() { //needed to pass on ie
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 1234561234", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999", "999999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("1234561234");
+		setTimeout(function() {
+			assert.equal(testmask.value, "123456-1234", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 12345-6", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999", "999999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		$("#testmask").Type("12345-6");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345-6___", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"], keepStatic: false}) - input 123456", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999", "999999-9999"],
+			keepStatic: false
+		}).mask(testmask);
+
+		testmask.focus();
 		$("#testmask").Type("123456");
 		setTimeout(function() {
-			start();
-			equal(testmask.value, "___6-54321", "Result " + testmask.value);
-			$("#testmask").remove();
+			assert.equal(testmask.value, "123456-____", "Result " + testmask.value);
+			done();
+
 		}, 0);
-	}, 0);
-});
+	});
 
-asyncTest("inputmask({ mask: ['9 AAA-AAA', 'A 999-999'] }) ", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ['9 AAA-AAA', 'A 999-999']
-	}).mask(testmask);
-
-	$("#testmask").Type("1abc");
-	setTimeout(function() {
-		equal(testmask.value, "1 ABC-___", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"] , keepStatic: true}) - input 123456", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999", "999999-9999"],
+			keepStatic: true
+		}).mask(testmask);
 
-asyncTest("inputmask({ mask: ['9 AAA-AAA', 'A 999-999'] }) ", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ['9 AAA-AAA', 'A 999-999']
-	}).mask(testmask);
-
-	$("#testmask").Type("a123");
-	setTimeout(function() {
-		equal(testmask.value, "A 123-___", "Result " + testmask.value);
-		start();
-		$("#testmask").remove();
-	}, 0);
-});
+		testmask.focus();
+		$("#testmask").Type("123456");
+		setTimeout(function() {
+			assert.equal(testmask.value, "12345-6___", "Result " + testmask.value);
+			done();
 
-test("inputmask({ mask: ['99.9', 'X'}) - annames", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	Inputmask({
-		mask: ["99.9", "X", "abc"],
-		definitions: {
-			"X": {
-				validator: "[xX]",
-				cardinality: 1,
-				casing: "upper"
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: [\"99999\", \"99999-9999\", \"999999-9999\"]]}) - input 123456 (rtl)", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" dir="rtl" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99999", "99999-9999", "999999-9999"]
+		}).mask(testmask);
+
+		testmask.focus();
+		setTimeout(function() { //needed to pass on ie
+			$("#testmask").Type("123456");
+			setTimeout(function() {
+				assert.equal(testmask.value, "___6-54321", "Result " + testmask.value);
+				done();
+			}, 0);
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: ['9 AAA-AAA', 'A 999-999'] }) ", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ['9 AAA-AAA', 'A 999-999']
+		}).mask(testmask);
+
+		$("#testmask").Type("1abc");
+		setTimeout(function() {
+			assert.equal(testmask.value, "1 ABC-___", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: ['9 AAA-AAA', 'A 999-999'] }) ", function(assert) {
+		var done = assert.async(),
+			$fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ['9 AAA-AAA', 'A 999-999']
+		}).mask(testmask);
+
+		$("#testmask").Type("a123");
+		setTimeout(function() {
+			assert.equal(testmask.value, "A 123-___", "Result " + testmask.value);
+			done();
+
+		}, 0);
+	});
+
+	qunit.test("inputmask({ mask: ['99.9', 'X'}) - annames", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask({
+			mask: ["99.9", "X", "abc"],
+			definitions: {
+				"X": {
+					validator: "[xX]",
+					cardinality: 1,
+					casing: "upper"
+				}
 			}
-		}
-	}).mask(testmask);
+		}).mask(testmask);
 
-	$("#testmask").Type("x");
-	equal(testmask.value, "X", "Result " + testmask.value);
-	$("#testmask").remove();
-});
+		$("#testmask").Type("x");
+		assert.equal(testmask.value, "X", "Result " + testmask.value);
+
+	});
 
-test("inputmask({ mask: [{ \"mask\": \"###-##-####\" }]) - lynxlive", function() {
-	var $fixture = $("#qunit-fixture");
-	$fixture.append('<input type="text" id="testmask" />');
-	var testmask = document.getElementById("testmask");
-	var ssns = [{
-		"mask": "###-##-####"
-	}];
-	Inputmask({
-		mask: ssns,
-		greedy: false,
-		definitions: {
-			'#': {
-				validator: "[0-9]",
-				cardinality: 1
+	qunit.test("inputmask({ mask: [{ \"mask\": \"###-##-####\" }]) - lynxlive", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		var ssns = [{
+			"mask": "###-##-####"
+		}];
+		Inputmask({
+			mask: ssns,
+			greedy: false,
+			definitions: {
+				'#': {
+					validator: "[0-9]",
+					cardinality: 1
+				}
 			}
-		}
-	}).mask(testmask);
+		}).mask(testmask);
 
-	$("#testmask").Type("123121234");
-	equal(testmask.value, "123-12-1234", "Result " + testmask.value);
-	$("#testmask").remove();
-});
+		$("#testmask").Type("123121234");
+		assert.equal(testmask.value, "123-12-1234", "Result " + testmask.value);
+
+	});
 
 });