Robin Herbots 9 years ago
parent
commit
325f05216e

+ 1 - 0
CHANGELOG.md

@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
 - replaced radixFocus option by positionCaretOnClick.  Allows choice for behavior of the caret on click. (none, lvp (default), radixFocus)
 - performance updates
 	- getmasklength
+	- set selective caching in getTests
 
 ### Fixed
 - Bug when typing after a fixed character #1299

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-11",
+  "version": "3.3.2-15",
   "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.3.2-11",
+  "version": "3.3.2-15",
   "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.3.2-11",
+  "version": "3.3.2-15",
   "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 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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(window.dependencyLib || jQuery, window.Inputmask);

+ 14 - 16
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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);
@@ -407,19 +407,18 @@
                                     maltMatches = matches.slice(), testPos = currentPos, matches = [];
                                     for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
                                     for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
-                                        var altMatch = maltMatches[ndx1];
+                                        var altMatch = maltMatches[ndx1], hasMatch = !1;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         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--), 
-                                                -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
+                                                hasMatch = altMatch.match.mask === altMatch2.match.mask, -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;
                                             }
                                         }
+                                        hasMatch || malternateMatches.push(altMatch);
                                     }
-                                    malternateMatches = malternateMatches.concat(maltMatches);
                                 }
                                 "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
                                     if (isFinite(ndx)) {
@@ -485,26 +484,25 @@
                     cardinality: 0,
                     optionality: !0,
                     casing: null,
-                    def: ""
+                    def: "",
+                    placeholder: ""
                 },
                 locator: [],
                 cd: cacheDependency
-            }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
+            }), void 0 !== ndxIntlzr && getMaskSet().tests[pos] ? $.extend(!0, [], matches) : (getMaskSet().tests[pos] = $.extend(!0, [], matches), 
+            getMaskSet().tests[pos]);
         }
         function getBufferTemplate() {
-            return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)), 
-            getMaskSet()._buffer;
+            return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1), 
+            void 0 === getMaskSet().buffer && getMaskSet()._buffer.slice()), getMaskSet()._buffer;
         }
         function getBuffer(noCache) {
-            if (void 0 === getMaskSet().buffer || noCache === !0) {
-                if (noCache === !0) for (var testNdx in getMaskSet().tests) void 0 === getMaskSet().validPositions[testNdx] && delete getMaskSet().tests[testNdx];
-                getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0);
-            }
-            return getMaskSet().buffer;
+            return (void 0 === getMaskSet().buffer || noCache === !0) && (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)), 
+            getMaskSet().buffer;
         }
         function refreshFromBuffer(start, end, buffer) {
             var i;
-            if (buffer = buffer, start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i], 
+            if (start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i], 
             delete getMaskSet().tests[i];
             for (i = start; end > i; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
         }
@@ -649,7 +647,7 @@
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
                     if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
-                        var testsFromPos = getTests(maskPos);
+                        var testsFromPos = getTests(maskPos).slice();
                         "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
                         var staticChar = determineTestTemplate(testsFromPos, !0);
                         staticChar && (staticChar = staticChar.match.placeholder || staticChar.match.def, 

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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(window.dependencyLib || jQuery, window.Inputmask);

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

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

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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(window.dependencyLib || jQuery, window.Inputmask);

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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);

+ 14 - 16
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -405,19 +405,18 @@
                                     maltMatches = matches.slice(), testPos = currentPos, matches = [];
                                     for (var i = 0; i < ndxInitializerClone.length; i++) ndxInitializer[i] = ndxInitializerClone[i];
                                     for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
-                                        var altMatch = maltMatches[ndx1];
+                                        var altMatch = maltMatches[ndx1], hasMatch = !1;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         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--), 
-                                                -1 === altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
+                                                hasMatch = altMatch.match.mask === altMatch2.match.mask, -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;
                                             }
                                         }
+                                        hasMatch || malternateMatches.push(altMatch);
                                     }
-                                    malternateMatches = malternateMatches.concat(maltMatches);
                                 }
                                 "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
                                     if (isFinite(ndx)) {
@@ -483,26 +482,25 @@
                     cardinality: 0,
                     optionality: !0,
                     casing: null,
-                    def: ""
+                    def: "",
+                    placeholder: ""
                 },
                 locator: [],
                 cd: cacheDependency
-            }), getMaskSet().tests[pos] = $.extend(!0, [], matches), getMaskSet().tests[pos];
+            }), void 0 !== ndxIntlzr && getMaskSet().tests[pos] ? $.extend(!0, [], matches) : (getMaskSet().tests[pos] = $.extend(!0, [], matches), 
+            getMaskSet().tests[pos]);
         }
         function getBufferTemplate() {
-            return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1)), 
-            getMaskSet()._buffer;
+            return void 0 === getMaskSet()._buffer && (getMaskSet()._buffer = getMaskTemplate(!1, 1), 
+            void 0 === getMaskSet().buffer && getMaskSet()._buffer.slice()), getMaskSet()._buffer;
         }
         function getBuffer(noCache) {
-            if (void 0 === getMaskSet().buffer || noCache === !0) {
-                if (noCache === !0) for (var testNdx in getMaskSet().tests) void 0 === getMaskSet().validPositions[testNdx] && delete getMaskSet().tests[testNdx];
-                getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0);
-            }
-            return getMaskSet().buffer;
+            return (void 0 === getMaskSet().buffer || noCache === !0) && (getMaskSet().buffer = getMaskTemplate(!0, getLastValidPosition(), !0)), 
+            getMaskSet().buffer;
         }
         function refreshFromBuffer(start, end, buffer) {
             var i;
-            if (buffer = buffer, start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i], 
+            if (start === !0) resetMaskSet(), start = 0, end = buffer.length; else for (i = start; end > i; i++) delete getMaskSet().validPositions[i], 
             delete getMaskSet().tests[i];
             for (i = start; end > i; i++) resetMaskSet(!0), buffer[i] !== opts.skipOptionalPartCharacter && isValid(i, buffer[i], !0, !0);
         }
@@ -647,7 +645,7 @@
                 var currentPosValid = getMaskSet().validPositions[maskPos];
                 if (!currentPosValid || null !== currentPosValid.match.fn || currentPosValid.match.def !== c && c !== opts.skipOptionalPartCharacter) {
                     if ((opts.insertMode || void 0 === getMaskSet().validPositions[seekNext(maskPos)]) && !isMask(maskPos, !0)) {
-                        var testsFromPos = getTests(maskPos);
+                        var testsFromPos = getTests(maskPos).slice();
                         "" === testsFromPos[testsFromPos.length - 1].match.def && testsFromPos.pop();
                         var staticChar = determineTestTemplate(testsFromPos, !0);
                         staticChar && (staticChar = staticChar.match.placeholder || staticChar.match.def, 

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 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-11
+* Version: 3.3.2-15
 */
 !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
+ 2 - 2
dist/min/jquery.inputmask.bundle.min.js


+ 92 - 95
js/inputmask.js

@@ -1071,16 +1071,13 @@
 									}
 									//fuzzy merge matches
 									for (var ndx1 = 0; ndx1 < maltMatches.length; ndx1++) {
-										var altMatch = maltMatches[ndx1];
+										var altMatch = maltMatches[ndx1], hasMatch = false;
 										altMatch.alternation = altMatch.alternation || loopNdxCnt;
 										for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
 											var altMatch2 = malternateMatches[ndx2];
 											//verify equality
 											if (altMatch.match.def === altMatch2.match.def && (typeof altIndex !== "string" || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1)) {
-												if (altMatch.match.mask === altMatch2.match.mask) {
-													maltMatches.splice(ndx1, 1);
-													ndx1--;
-												}
+												hasMatch = altMatch.match.mask === altMatch2.match.mask;
 												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
@@ -1088,10 +1085,11 @@
 												break;
 											}
 										}
+										if (!hasMatch) {
+											malternateMatches.push(altMatch);
+										}
 									}
-									malternateMatches = malternateMatches.concat(maltMatches);
 								}
-
 								if (typeof altIndex == "string") { //filter matches
 									malternateMatches = $.map(malternateMatches, function (lmnt, ndx) {
 										if (isFinite(ndx)) {
@@ -1214,6 +1212,7 @@
 
 					return temp;
 				}
+
 				return tests;
 			}
 
@@ -1255,13 +1254,17 @@
 						cardinality: 0,
 						optionality: true,
 						casing: null,
-						def: ""
+						def: "",
+						placeholder: ""
 					},
 					locator: [],
 					cd: cacheDependency
 				});
 			}
 
+			if (ndxIntlzr !== undefined && getMaskSet().tests[pos]) { //prioritize full tests for caching
+				return $.extend(true, [], matches);
+			}
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
 			//console.log(pos + " - " + JSON.stringify(matches));
 			return getMaskSet().tests[pos];
@@ -1271,19 +1274,15 @@
 			if (getMaskSet()._buffer === undefined) {
 				//generate template
 				getMaskSet()._buffer = getMaskTemplate(false, 1);
+				if (getMaskSet().buffer === undefined) {
+					getMaskSet()._buffer.slice();
+				}
 			}
 			return getMaskSet()._buffer;
 		}
 
 		function getBuffer(noCache) {
 			if (getMaskSet().buffer === undefined || noCache === true) {
-				if (noCache === true) {
-					for (var testNdx in getMaskSet().tests) {
-						if (getMaskSet().validPositions[testNdx] === undefined) {
-							delete getMaskSet().tests[testNdx];
-						}
-					}
-				}
 				getMaskSet().buffer = getMaskTemplate(true, getLastValidPosition(), true);
 			}
 			return getMaskSet().buffer;
@@ -1291,7 +1290,6 @@
 
 		function refreshFromBuffer(start, end, buffer) {
 			var i;
-			buffer = buffer;
 			if (start === true) {
 				resetMaskSet();
 				start = 0;
@@ -1357,92 +1355,92 @@
 			}
 
 			function _isValid(position, c, strict, fromSetValid) {
-				var rslt = false;
+				var rslt = false, validatedDefs = {};
 				$.each(getTests(position), function (ndx, tst) {
-					var test = tst.match;
-					var loopend = c ? 1 : 0,
-						chrs = "";
-					for (var i = test.cardinality; i > loopend; i--) {
-						chrs += getBufferElement(position - (i - 1));
-					}
-					if (c) {
-						chrs += c;
-					}
-
-					//make sure the buffer is set and correct
-					getBuffer(true);
-					//return is false or a json object => { pos: ??, c: ??} or true
-					rslt = test.fn != null ?
-						test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? //non mask
-					{
-						c: test.placeholder || test.def,
-						pos: position
-					} : false;
-
-					if (rslt !== false) {
-						var elem = rslt.c !== undefined ? rslt.c : c;
-						elem = (elem === opts.skipOptionalPartCharacter && test.fn === null) ? (test.placeholder || test.def) : elem;
-
-						var validatedPos = position,
-							possibleModifiedBuffer = getBuffer();
-
-						if (rslt.remove !== undefined) { //remove position(s)
-							if (!$.isArray(rslt.remove)) rslt.remove = [rslt.remove];
-							$.each(rslt.remove.sort(function (a, b) {
-								return b - a;
-							}), function (ndx, lmnt) {
-								stripValidPositions(lmnt, lmnt + 1, true);
-							});
+						var test = tst.match,
+							loopend = c ? 1 : 0,
+							chrs = "";
+						for (var i = test.cardinality; i > loopend; i--) {
+							chrs += getBufferElement(position - (i - 1));
 						}
-						if (rslt.insert !== undefined) { //insert position(s)
-							if (!$.isArray(rslt.insert)) rslt.insert = [rslt.insert];
-							$.each(rslt.insert.sort(function (a, b) {
-								return a - b;
-							}), function (ndx, lmnt) {
-								isValid(lmnt.pos, lmnt.c, false, fromSetValid);
-							});
+						if (c) {
+							chrs += c;
 						}
 
-						if (rslt.refreshFromBuffer) {
-							var refresh = rslt.refreshFromBuffer;
-							strict = true;
-							refreshFromBuffer(refresh === true ? refresh : refresh.start, refresh.end, possibleModifiedBuffer);
-							if (rslt.pos === undefined && rslt.c === undefined) {
-								rslt.pos = getLastValidPosition();
-								return false; //breakout if refreshFromBuffer && nothing to insert
+						//make sure the buffer is set and correct
+						getBuffer(true);
+						//return is false or a json object => { pos: ??, c: ??} or true
+						rslt = test.fn != null ?
+							test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? //non mask
+						{
+							c: test.placeholder || test.def,
+							pos: position
+						} : false;
+
+						if (rslt !== false) {
+							var elem = rslt.c !== undefined ? rslt.c : c;
+							elem = (elem === opts.skipOptionalPartCharacter && test.fn === null) ? (test.placeholder || test.def) : elem;
+
+							var validatedPos = position,
+								possibleModifiedBuffer = getBuffer();
+
+							if (rslt.remove !== undefined) { //remove position(s)
+								if (!$.isArray(rslt.remove)) rslt.remove = [rslt.remove];
+								$.each(rslt.remove.sort(function (a, b) {
+									return b - a;
+								}), function (ndx, lmnt) {
+									stripValidPositions(lmnt, lmnt + 1, true);
+								});
 							}
-							validatedPos = rslt.pos !== undefined ? rslt.pos : position;
-							if (validatedPos !== position) {
-								rslt = $.extend(rslt, isValid(validatedPos, elem, true, fromSetValid)); //revalidate new position strict
-								return false;
+							if (rslt.insert !== undefined) { //insert position(s)
+								if (!$.isArray(rslt.insert)) rslt.insert = [rslt.insert];
+								$.each(rslt.insert.sort(function (a, b) {
+									return a - b;
+								}), function (ndx, lmnt) {
+									isValid(lmnt.pos, lmnt.c, false, fromSetValid);
+								});
 							}
 
-						} else if (rslt !== true && rslt.pos !== undefined && rslt.pos !== position) { //their is a position offset
-							validatedPos = rslt.pos;
-							refreshFromBuffer(position, validatedPos, getBuffer().slice());
-							if (validatedPos !== position) {
-								rslt = $.extend(rslt, isValid(validatedPos, elem, true)); //revalidate new position strict
-								return false;
+							if (rslt.refreshFromBuffer) {
+								var refresh = rslt.refreshFromBuffer;
+								strict = true;
+								refreshFromBuffer(refresh === true ? refresh : refresh.start, refresh.end, possibleModifiedBuffer);
+								if (rslt.pos === undefined && rslt.c === undefined) {
+									rslt.pos = getLastValidPosition();
+									return false; //breakout if refreshFromBuffer && nothing to insert
+								}
+								validatedPos = rslt.pos !== undefined ? rslt.pos : position;
+								if (validatedPos !== position) {
+									rslt = $.extend(rslt, isValid(validatedPos, elem, true, fromSetValid)); //revalidate new position strict
+									return false;
+								}
+
+							} else if (rslt !== true && rslt.pos !== undefined && rslt.pos !== position) { //their is a position offset
+								validatedPos = rslt.pos;
+								refreshFromBuffer(position, validatedPos, getBuffer().slice());
+								if (validatedPos !== position) {
+									rslt = $.extend(rslt, isValid(validatedPos, elem, true)); //revalidate new position strict
+									return false;
+								}
 							}
-						}
 
-						if (rslt !== true && rslt.pos === undefined && rslt.c === undefined) {
-							return false; //breakout if nothing to insert
-						}
+							if (rslt !== true && rslt.pos === undefined && rslt.c === undefined) {
+								return false; //breakout if nothing to insert
+							}
 
-						if (ndx > 0) {
-							resetMaskSet(true);
-						}
+							if (ndx > 0) {
+								resetMaskSet(true);
+							}
 
-						if (!setValidPosition(validatedPos, $.extend({}, tst, {
-								"input": casing(elem, test, validatedPos)
-							}), fromSetValid, isSelection(pos))) {
-							rslt = false;
+							if (!setValidPosition(validatedPos, $.extend({}, tst, {
+									"input": casing(elem, test, validatedPos)
+								}), fromSetValid, isSelection(pos))) {
+								rslt = false;
+							}
+							return false; //break from $.each
 						}
-						return false; //break from $.each
 					}
-				});
-
+				);
 				return rslt;
 			}
 
@@ -1563,7 +1561,7 @@
 				return false;
 			}
 
-			//set alternator choice on previous skipped placeholder positions
+//set alternator choice on previous skipped placeholder positions
 			function trackbackAlternations(originalPos, newPos) {
 				var vp = getMaskSet().validPositions[newPos],
 					targetLocator = vp.locator,
@@ -1591,16 +1589,15 @@
 				}
 			}
 
-
 			var result = false,
 				positionsClone = $.extend(true, {}, getMaskSet().validPositions); //clone the currentPositions
 
-			//Check for a nonmask before the pos
-			//find previous valid
+//Check for a nonmask before the pos
+//find previous valid
 			for (var pndx = maskPos - 1; pndx > -1; pndx--) {
 				if (getMaskSet().validPositions[pndx]) break;
 			}
-			////fill missing nonmask and valid placeholders
+////fill missing nonmask and valid placeholders
 			var testTemplate, generatedPos;
 			for (pndx++; pndx < maskPos; pndx++) {
 				if (getMaskSet().validPositions[pndx] === undefined &&
@@ -1629,7 +1626,7 @@
 							"caret": seekNext(maskPos)
 						};
 					} else if ((opts.insertMode || getMaskSet().validPositions[seekNext(maskPos)] === undefined) && !isMask(maskPos, true)) { //does the input match on a further position?
-						var testsFromPos = getTests(maskPos);
+						var testsFromPos = getTests(maskPos).slice();
 						if (testsFromPos[testsFromPos.length - 1].match.def === "") testsFromPos.pop();
 						var staticChar = determineTestTemplate(testsFromPos, true);
 						if (staticChar) {

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

@@ -108,6 +108,7 @@
 					opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
 					if (opts.radixPoint === ",") opts.max = opts.max.replace(opts.radixPoint, ".");
 				}
+
 				return mask;
 			},
 			placeholder: "",

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.2-11",
+  "version": "3.3.2-15",
   "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"
 	}
 });

+ 54 - 72
qunit/tests_paste.js

@@ -12,8 +12,8 @@ define([
 ], function(qunit, $, Inputmask) {
 
 	qunit.module("Paste value");
-	asyncTest("inputmask(\"+7 (999) 999-99-99\") ~ paste \"+79114041112\"", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+7 (999) 999-99-99\") ~ paste \"+79114041112\"", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+7 (999) 999-99-99").mask(testmask);
@@ -22,13 +22,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+7 (911) 404-11-12", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 
 	});
-	asyncTest("inputmask(\"+7 (999) 999-99-99\") ~ paste \"+7 (9114041112___)\"", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+7 (999) 999-99-99\") ~ paste \"+7 (9114041112___)\"", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+7 (999) 999-99-99").mask(testmask);
@@ -37,14 +36,13 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+7 (911) 404-11-12", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 
 	});
 
-	asyncTest("inputmask(\"+7 (999) 999-99-99\") ~ paste \"0079114041112\" - monoblaine", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+7 (999) 999-99-99\") ~ paste \"0079114041112\" - monoblaine", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+7 (999) 999-99-99", {
@@ -59,14 +57,13 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+7 (911) 404-11-12", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 
 	});
 
-	asyncTest("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"+32(123)12-12-12\"", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"+32(123)12-12-12\"", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+32(999)99-99-99", {
@@ -78,14 +75,13 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+32(123)12-12-12", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
 
-	asyncTest("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"(123)12-12-12\"", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"(123)12-12-12\"", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+32(999)99-99-99", {
@@ -97,13 +93,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+32(123)12-12-12", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"+32473890428\"", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+32(999)99-99-99\", { nojumps: true, nojumpsThreshold: 4 }) ~ paste \"+32473890428\"", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+32(999)99-99-99", {
@@ -115,13 +110,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+32(473)89-04-28", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("inputmask(\"+31 9999999999\") ~ paste \"3112345678\" - jason16v", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+31 9999999999\") ~ paste \"3112345678\" - jason16v", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+31 9999999999").mask(testmask);
@@ -130,13 +124,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+31 3112345678", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("inputmask(\"+31 9999999999\") ~ paste \"+3112345678\" - jason16v", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("inputmask(\"+31 9999999999\") ~ paste \"+3112345678\" - jason16v", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("+31 9999999999").mask(testmask);
@@ -145,13 +138,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "+31 12345678__", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("99.999.999/9999-99 numericInput ~ paste __-____/..__79100085302751__-____/..__ - imbelo", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("99.999.999/9999-99 numericInput ~ paste __-____/..__79100085302751__-____/..__ - imbelo", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask({
@@ -163,13 +155,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "79.100.085/3027-51", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ $123.22 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ $123.22 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("body");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -178,13 +169,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ 123.22", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ $-123.22 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ $-123.22 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -193,13 +183,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ -123.22", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ 1000.00 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ 1000.00 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -208,13 +197,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ 1,000.00", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ -1000.00 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ -1000.00 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -223,13 +211,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ -1,000.00", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ $1000.00 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ $1000.00 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -238,13 +225,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ 1,000.00", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ $-1000.00 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ $-1000.00 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -253,13 +239,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "$ -1,000.00", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("currency ~ 000.02 - sjk07", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("currency ~ 000.02 - sjk07", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask('currency').mask(testmask);
@@ -269,13 +254,12 @@ define([
 		setTimeout(function() {
 			$(testmask).trigger("blur");
 			equal(testmask.value, "$ 0.02", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("02.999.999 ~ paste 02.024.900 - tnavarra", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("02.999.999 ~ paste 02.024.900 - tnavarra", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("02.999.999").mask(testmask);
@@ -284,13 +268,12 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "02.024.900", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 
-	asyncTest("R9999999999 ~ paste 1234567890 - s-a", function() {
-		var $fixture = $("#qunit-fixture");
+	qunit.test("R9999999999 ~ paste 1234567890 - s-a", function(assert) {
+		var done = assert.async(), $fixture = $("#qunit-fixture");
 		$fixture.append('<input type="text" id="testmask" />');
 		var testmask = document.getElementById("testmask");
 		Inputmask("R9999999999", {
@@ -303,8 +286,7 @@ define([
 
 		setTimeout(function() {
 			equal(testmask.value, "R1234567890", "Result " + testmask.value);
-			start();
-			$("#testmask").remove();
+			done();
 		}, 0);
 	});
 });