Browse Source

improve mergelocator + drop cardinality + prevalidators in definitions

Robin Herbots 8 years ago
parent
commit
7ea82df312
48 changed files with 125 additions and 298 deletions
  1. 1 0
      CHANGELOG.md
  2. 2 29
      README.md
  3. 1 1
      bower.json
  4. 1 1
      component.json
  5. 1 1
      composer.json
  6. 1 1
      dist/inputmask/bindings/inputmask.binding.js
  7. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js
  8. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js
  9. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.js
  10. 1 1
      dist/inputmask/global/document.js
  11. 1 1
      dist/inputmask/global/window.js
  12. 1 1
      dist/inputmask/inputmask.date.extensions.js
  13. 3 11
      dist/inputmask/inputmask.extensions.js
  14. 27 68
      dist/inputmask/inputmask.js
  15. 1 1
      dist/inputmask/inputmask.numeric.extensions.js
  16. 1 1
      dist/inputmask/inputmask.phone.extensions.js
  17. 1 1
      dist/inputmask/jquery.inputmask.js
  18. 1 1
      dist/inputmask/phone-codes/phone-be.js
  19. 1 1
      dist/inputmask/phone-codes/phone-ca.js
  20. 1 1
      dist/inputmask/phone-codes/phone-nl.js
  21. 1 1
      dist/inputmask/phone-codes/phone-ru.js
  22. 1 1
      dist/inputmask/phone-codes/phone-uk.js
  23. 1 1
      dist/inputmask/phone-codes/phone-us.js
  24. 1 1
      dist/inputmask/phone-codes/phone.js
  25. 30 79
      dist/jquery.inputmask.bundle.js
  26. 1 1
      dist/min/inputmask/bindings/inputmask.binding.min.js
  27. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js
  28. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js
  29. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js
  30. 1 1
      dist/min/inputmask/global/document.min.js
  31. 1 1
      dist/min/inputmask/global/window.min.js
  32. 1 1
      dist/min/inputmask/inputmask.date.extensions.min.js
  33. 2 2
      dist/min/inputmask/inputmask.extensions.min.js
  34. 2 2
      dist/min/inputmask/inputmask.min.js
  35. 1 1
      dist/min/inputmask/inputmask.numeric.extensions.min.js
  36. 1 1
      dist/min/inputmask/inputmask.phone.extensions.min.js
  37. 1 1
      dist/min/inputmask/jquery.inputmask.min.js
  38. 1 1
      dist/min/inputmask/phone-codes/phone-be.min.js
  39. 1 1
      dist/min/inputmask/phone-codes/phone-ca.min.js
  40. 1 1
      dist/min/inputmask/phone-codes/phone-nl.min.js
  41. 1 1
      dist/min/inputmask/phone-codes/phone-ru.min.js
  42. 1 1
      dist/min/inputmask/phone-codes/phone-uk.min.js
  43. 1 1
      dist/min/inputmask/phone-codes/phone-us.min.js
  44. 1 1
      dist/min/inputmask/phone-codes/phone.min.js
  45. 2 2
      dist/min/jquery.inputmask.bundle.min.js
  46. 1 9
      js/inputmask.extensions.js
  47. 17 58
      js/inputmask.js
  48. 1 1
      package.json

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
 - new datetime alias (WIP)
 
 ### Updates
+- drop prevalidator and cardinality support in definitions
 - better determination of the NdxInitializer (alternations)
 - disable autocorrect on safari when disablePredictiveText is used
 - fix in determineTestTemplate.  Impacts alternations.

+ 2 - 29
README.md

@@ -283,7 +283,6 @@ $(document).ready(function(){
     definitions: {
       '*': {
         validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
-        cardinality: 1,
         casing: "lower"
       }
     }
@@ -306,7 +305,6 @@ $("selector").inputmask("(99.9)|(X)", {
   definitions: {
     "X": {
       validator: "[xX]",
-      cardinality: 1,
       casing: "upper"
     }
   }
@@ -321,7 +319,6 @@ $("selector").inputmask({
   definitions: {
     "X": {
       validator: "[xX]",
-      cardinality: 1,
       casing: "upper"
     }
   }
@@ -368,41 +365,24 @@ The return value of a validator can be true,  false or a command object.
   - true => refresh validPositions from the complete buffer
   - { start: , end: } => refresh from start to end
 
-### cardinality
-Cardinality specifies how many characters are represented and validated for the definition.
-
-### prevalidator(chrs, maskset, pos, strict, opts)
-The prevalidator option is used to validate the characters before the definition cardinality is reached. (see 'j' example)
-
 ### definitionSymbol
 When you insert or delete characters, they are only shifted when the definition type is the same.  This behavior can be overridden by giving a definitionSymbol. (see example x, y, z, which can be used for ip-address masking, the validation is different, but it is allowed to shift the characters between the definitions)
 
 ```javascript
 Inputmask.extendDefinitions({
   'f': {  //masksymbol
-    "validator": "[0-9\(\)\.\+/ ]",
-    "cardinality": 1,
-    'prevalidator': null
+    "validator": "[0-9\(\)\.\+/ ]"
   },
   'g': {
     "validator": function (chrs, buffer, pos, strict, opts) {
       //do some logic and return true, false, or { "pos": new position, "c": character to place }
     }
-    "cardinality": 1,
-    'prevalidator': null
   },
   'j': { //basic year
-    validator: "(19|20)\\d{2}",
-    cardinality: 4,
-    prevalidator: [
-      { validator: "[12]", cardinality: 1 },
-      { validator: "(19|20)", cardinality: 2 },
-      { validator: "(19|20)\\d", cardinality: 3 }
-    ]
+    validator: "(19|20)\\d{2}"
   },
   'x': {
     validator: "[0-2]",
-    cardinality: 1,
     definitionSymbol: "i" //this allows shifting values from other definitions, with the same masksymbol or definitionSymbol
   },
   'y': {
@@ -410,7 +390,6 @@ Inputmask.extendDefinitions({
       var valExp2 = new RegExp("2[0-5]|[01][0-9]");
       return valExp2.test(buffer[pos - 1] + chrs);
     },
-    cardinality: 1,
     definitionSymbol: "i"
   },
   'z': {
@@ -418,7 +397,6 @@ Inputmask.extendDefinitions({
       var valExp3 = new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]");
       return valExp3.test(buffer[pos - 2] + buffer[pos - 1] + chrs);
     },
-    cardinality: 1,
     definitionSymbol: "i"
   }
 });
@@ -437,12 +415,10 @@ Inputmask.extendDefaults({
 Inputmask.extendDefinitions({
   'A': {
     validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-    cardinality: 1,
     casing: "upper" //auto uppercasing
   },
   '+': {
     validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-    cardinality: 1,
     casing: "upper"
   }
 });
@@ -1039,7 +1015,6 @@ Inputmask("(99 99 999999)|(i{+})", {
   definitions: {
     "i": {
       validator: ".",
-      cardinality: 1,
       definitionSymbol: "*"
     }
   },
@@ -1154,12 +1129,10 @@ You can define within a definition to automatically apply some casing on the ent
 Inputmask.extendDefinitions({
   'A': {
     validator: "[A-Za-z]",
-    cardinality: 1,
     casing: "upper" //auto uppercasing
   },
   '+': {
     validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
-    cardinality: 1,
     casing: "upper"
   }
 });

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-66",
+  "version": "4.0.0-68",
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "inputmask",
 	"repository": "robinherbots/Inputmask",
 	"description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-	"version": "4.0.0-66",
+	"version": "4.0.0-68",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "4.0.0-66",
+  "version": "4.0.0-68",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 1 - 1
dist/inputmask/bindings/inputmask.binding.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/global/document.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 1 - 1
dist/inputmask/global/window.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 "function" == typeof define && define.amd ? define(function() {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 3 - 11
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {
@@ -12,25 +12,21 @@
     return Inputmask.extendDefinitions({
         A: {
             validator: "[A-Za-zА-яЁёÀ-ÿµ]",
-            cardinality: 1,
             casing: "upper"
         },
         "&": {
             validator: "[0-9A-Za-zА-яЁёÀ-ÿµ]",
-            cardinality: 1,
             casing: "upper"
         },
         "#": {
             validator: "[0-9A-Fa-f]",
-            cardinality: 1,
             casing: "upper"
         }
     }), Inputmask.extendAliases({
         url: {
             definitions: {
                 i: {
-                    validator: ".",
-                    cardinality: 1
+                    validator: "."
                 }
             },
             mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
@@ -46,8 +42,7 @@
                         return pos - 1 > -1 && "." !== maskset.buffer[pos - 1] ? (chrs = maskset.buffer[pos - 1] + chrs, 
                         chrs = pos - 2 > -1 && "." !== maskset.buffer[pos - 2] ? maskset.buffer[pos - 2] + chrs : "0" + chrs) : chrs = "00" + chrs, 
                         new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
-                    },
-                    cardinality: 1
+                    }
                 }
             },
             onUnMask: function(maskedValue, unmaskedValue, opts) {
@@ -64,12 +59,10 @@
             definitions: {
                 "*": {
                     validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",
-                    cardinality: 1,
                     casing: "lower"
                 },
                 "-": {
                     validator: "[0-9A-Za-z-]",
-                    cardinality: 1,
                     casing: "lower"
                 }
             },
@@ -86,7 +79,6 @@
             definitions: {
                 V: {
                     validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
-                    cardinality: 1,
                     casing: "upper"
                 }
             },

+ 27 - 68
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {
@@ -155,11 +155,13 @@
                         return targetAlternation !== undefined ? resolveNdxInitializer(pos, alternateNdx) : undefined;
                     }
                     function setMergeLocators(targetMatch, altMatch) {
-                        if (targetMatch.mloc = targetMatch.mloc || {}, targetMatch.mloc[targetMatch.locator[targetMatch.alternation]] === undefined && (targetMatch.mloc[targetMatch.locator[targetMatch.alternation]] = targetMatch.locator.slice()), 
+                        targetMatch.mloc = targetMatch.mloc || {};
+                        var locNdx = targetMatch.locator[targetMatch.alternation];
+                        if ("string" == typeof locNdx && (locNdx = locNdx.split(",")[0]), targetMatch.mloc[locNdx] === undefined && (targetMatch.mloc[locNdx] = targetMatch.locator.slice()), 
                         altMatch !== undefined) {
-                            var locNdx = altMatch.locator[altMatch.alternation];
-                            "string" == typeof locNdx && (locNdx = locNdx.split("")[0]), targetMatch.mloc[locNdx] === undefined && (targetMatch.mloc[locNdx] = altMatch.mloc[locNdx] || altMatch.locator.slice()), 
-                            targetMatch.locator[targetMatch.alternation] = (altMatch.locator[altMatch.alternation] + "," + targetMatch.locator[targetMatch.alternation]).split(",").sort().join(",");
+                            for (var ndx in altMatch.mloc) "string" == typeof ndx && (ndx = ndx.split(",")[0]), 
+                            targetMatch.mloc[ndx] === undefined && (targetMatch.mloc[ndx] = altMatch.mloc[ndx]);
+                            targetMatch.locator[targetMatch.alternation] = Object.keys(targetMatch.mloc).join(",");
                         }
                     }
                     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;
@@ -272,7 +274,6 @@
             return (0 === matches.length || insertStop) && matches.push({
                 match: {
                     fn: null,
-                    cardinality: 0,
                     optionality: !0,
                     casing: null,
                     def: "",
@@ -340,8 +341,8 @@
             function _isValid(position, c, strict) {
                 var rslt = !1;
                 return $.each(getTests(position), function(ndx, tst) {
-                    for (var test = tst.match, loopend = c ? 1 : 0, chrs = "", i = test.cardinality; i > loopend; i--) chrs += getBufferElement(position - (i - 1));
-                    if (c && (chrs += c), getBuffer(!0), !1 !== (rslt = null != test.fn ? test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
+                    var test = tst.match;
+                    if (getBuffer(!0), !1 !== (rslt = null != test.fn ? test.fn.test(c, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && "" !== test.def && {
                         c: getPlaceholder(position, test, !0) || test.def,
                         pos: position
                     })) {
@@ -527,9 +528,6 @@
             for (;--position > 0 && (!0 === newBlock && !0 !== getTest(position).match.newBlockMarker || !0 !== newBlock && !isMask(position) && ((tests = getTests(position)).length < 2 || 2 === tests.length && "" === tests[1].match.def)); ) ;
             return position;
         }
-        function getBufferElement(position) {
-            return getMaskSet().validPositions[position] === undefined ? getPlaceholder(position) : getMaskSet().validPositions[position].input;
-        }
         function writeBuffer(input, buffer, caretPos, event, triggerInputEvent) {
             if (event && $.isFunction(opts.onBeforeWrite)) {
                 var result = opts.onBeforeWrite.call(inputmask, event, buffer, caretPos, opts);
@@ -613,7 +611,7 @@
             "number" == typeof begin) {
                 begin = translatePosition(begin), end = "number" == typeof (end = translatePosition(end)) ? end : begin;
                 var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
-                if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, !1 === opts.insertMode && begin === end && end++, 
+                if (input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0, !1 !== opts.insertMode || begin !== end || mobile || end++, 
                 input.inputmask.caretPos = {
                     begin: begin,
                     end: end
@@ -733,7 +731,8 @@
                 maskTemplate += "</span>") : (isStatic = !0, maskTemplate += "<span class='im-static'>");
             }
             function handleCaret(force) {
-                !0 !== force && pos !== caretPos.begin || document.activeElement !== input || (maskTemplate += "<span class='im-caret' style='border-right-width: 1px;border-right-style: solid;'></span>");
+                !0 !== force && pos !== caretPos.begin || document.activeElement !== input || (caretPos.begin === caretPos.end ? maskTemplate += '<span class="im-caret" style="border-right-width: 1px;border-right-style: solid;">' : maskTemplate += '<span class="im-caret-select">'), 
+                !0 !== force && pos !== caretPos.end || document.activeElement !== input || (maskTemplate += "</span>");
             }
             var test, testPos, ndxIntlzr, maskTemplate = "", isStatic = !1, pos = 0;
             if (colorMask !== undefined) {
@@ -1274,17 +1273,14 @@
         definitions: {
             "9": {
                 validator: "[0-91-9]",
-                cardinality: 1,
                 definitionSymbol: "*"
             },
             a: {
                 validator: "[A-Za-zА-яЁёÀ-ÿµ]",
-                cardinality: 1,
                 definitionSymbol: "*"
             },
             "*": {
-                validator: "[0-91-9A-Za-zА-яЁёÀ-ÿµ]",
-                cardinality: 1
+                validator: "[0-91-9A-Za-zА-яЁёÀ-ÿµ]"
             }
         },
         aliases: {},
@@ -1402,7 +1398,6 @@
                 var prevMatch = mtoken.matches[position - 1];
                 if (regexMask) 0 === element.indexOf("[") || escaped && /\\d|\\s|\\w]/i.test(element) || "." === element ? mtoken.matches.splice(position++, 0, {
                     fn: new RegExp(element, opts.casing ? "i" : ""),
-                    cardinality: 1,
                     optionality: mtoken.isOptional,
                     newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
                     casing: null,
@@ -1412,7 +1407,6 @@
                 }) : (escaped && (element = element[element.length - 1]), $.each(element.split(""), function(ndx, lmnt) {
                     prevMatch = mtoken.matches[position - 1], mtoken.matches.splice(position++, 0, {
                         fn: null,
-                        cardinality: 0,
                         optionality: mtoken.isOptional,
                         newBlockMarker: prevMatch === undefined || prevMatch.def !== lmnt && null !== prevMatch.fn,
                         casing: null,
@@ -1422,44 +1416,25 @@
                     });
                 })), escaped = !1; else {
                     var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
-                    if (maskdef && !escaped) {
-                        for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) {
-                            var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality;
-                            mtoken.matches.splice(position++, 0, {
-                                fn: validator ? "string" == typeof validator ? new RegExp(validator, opts.casing ? "i" : "") : new function() {
-                                    this.test = validator;
-                                }() : new RegExp("."),
-                                cardinality: cardinality || 1,
-                                optionality: mtoken.isOptional,
-                                newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
-                                casing: maskdef.casing,
-                                def: maskdef.definitionSymbol || element,
-                                placeholder: maskdef.placeholder,
-                                nativeDef: element
-                            }), prevMatch = mtoken.matches[position - 1];
-                        }
-                        mtoken.matches.splice(position++, 0, {
-                            fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() {
-                                this.test = maskdef.validator;
-                            }() : new RegExp("."),
-                            cardinality: maskdef.cardinality,
-                            optionality: mtoken.isOptional,
-                            newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
-                            casing: maskdef.casing,
-                            def: maskdef.definitionSymbol || element,
-                            placeholder: maskdef.placeholder,
-                            nativeDef: element
-                        });
-                    } else mtoken.matches.splice(position++, 0, {
+                    maskdef && !escaped ? mtoken.matches.splice(position++, 0, {
+                        fn: maskdef.validator ? "string" == typeof maskdef.validator ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() {
+                            this.test = maskdef.validator;
+                        }() : new RegExp("."),
+                        optionality: mtoken.isOptional,
+                        newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
+                        casing: maskdef.casing,
+                        def: maskdef.definitionSymbol || element,
+                        placeholder: maskdef.placeholder,
+                        nativeDef: element
+                    }) : (mtoken.matches.splice(position++, 0, {
                         fn: null,
-                        cardinality: 0,
                         optionality: mtoken.isOptional,
                         newBlockMarker: prevMatch === undefined || prevMatch.def !== element && null !== prevMatch.fn,
                         casing: null,
                         def: opts.staticDefinitionSymbol || element,
                         placeholder: opts.staticDefinitionSymbol !== undefined ? element : undefined,
                         nativeDef: element
-                    }), escaped = !1;
+                    }), escaped = !1);
                 }
             }
             function verifyGroupMarker(maskToken) {
@@ -1588,15 +1563,8 @@
         var specials = [ "/", ".", "*", "+", "?", "|", "(", ")", "[", "]", "{", "}", "\\", "$", "^" ];
         return str.replace(new RegExp("(\\" + specials.join("|\\") + ")", "gim"), "\\$1");
     }, Inputmask.keyCode = {
-        ALT: 18,
         BACKSPACE: 8,
         BACKSPACE_SAFARI: 127,
-        CAPS_LOCK: 20,
-        COMMA: 188,
-        COMMAND: 91,
-        COMMAND_LEFT: 91,
-        COMMAND_RIGHT: 93,
-        CONTROL: 17,
         DELETE: 46,
         DOWN: 40,
         END: 35,
@@ -1605,22 +1573,13 @@
         HOME: 36,
         INSERT: 45,
         LEFT: 37,
-        MENU: 93,
-        NUMPAD_ADD: 107,
-        NUMPAD_DECIMAL: 110,
-        NUMPAD_DIVIDE: 111,
-        NUMPAD_ENTER: 108,
-        NUMPAD_MULTIPLY: 106,
-        NUMPAD_SUBTRACT: 109,
         PAGE_DOWN: 34,
         PAGE_UP: 33,
-        PERIOD: 190,
         RIGHT: 39,
-        SHIFT: 16,
         SPACE: 32,
         TAB: 9,
         UP: 38,
-        WINDOWS: 91,
-        X: 88
+        X: 88,
+        CONTROL: 17
     }, Inputmask;
 });

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-be.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ca.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-nl.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ru.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-uk.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-us.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 !function(factory) {

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


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


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


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

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

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


+ 1 - 1
dist/min/inputmask/global/document.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 "function"==typeof define&&define.amd?define(function(){return document}):"object"==typeof exports&&(module.exports=document);

+ 1 - 1
dist/min/inputmask/global/window.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-66
+* Version: 4.0.0-68
 */
 
 "function"==typeof define&&define.amd?define(function(){return window}):"object"==typeof exports&&(module.exports=window);

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


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


File diff suppressed because it is too large
+ 2 - 2
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/jquery.inputmask.min.js


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


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


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


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


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


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


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


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


+ 1 - 9
js/inputmask.extensions.js

@@ -21,17 +21,14 @@
 	Inputmask.extendDefinitions({
 		"A": {
 			validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-			cardinality: 1,
 			casing: "upper" //auto uppercasing
 		},
 		"&": { //alfanumeric uppercasing
 			validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-			cardinality: 1,
 			casing: "upper"
 		},
 		"#": { //hexadecimal
 			validator: "[0-9A-Fa-f]",
-			cardinality: 1,
 			casing: "upper"
 		}
 	});
@@ -40,7 +37,6 @@
 			definitions: {
 				"i": {
 					validator: ".",
-					cardinality: 1
 				}
 			},
 			mask: "(\\http://)|(\\http\\s://)|(ftp://)|(ftp\\s://)i{+}",
@@ -60,8 +56,7 @@
 							} else chrs = "0" + chrs;
 						} else chrs = "00" + chrs;
 						return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
-					},
-					cardinality: 1
+					}
 				}
 			},
 			onUnMask: function (maskedValue, unmaskedValue, opts) {
@@ -82,12 +77,10 @@
 			definitions: {
 				"*": {
 					validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
-					cardinality: 1,
 					casing: "lower"
 				},
 				"-": {
 					validator: "[0-9A-Za-z\-]",
-					cardinality: 1,
 					casing: "lower"
 				}
 			},
@@ -106,7 +99,6 @@
 			definitions: {
 				'V': {
 					validator: "[A-HJ-NPR-Za-hj-npr-z\\d]",
-					cardinality: 1,
 					casing: "upper"
 				}
 			},

+ 17 - 58
js/inputmask.js

@@ -123,17 +123,14 @@
         definitions: {
             "9": { //\uFF11-\uFF19 #1606
                 validator: "[0-9\uFF11-\uFF19]",
-                cardinality: 1,
                 definitionSymbol: "*"
             },
             "a": { //\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5 #76
                 validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-                cardinality: 1,
                 definitionSymbol: "*"
             },
             "*": {
-                validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]",
-                cardinality: 1
+                validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
             }
         },
         aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
@@ -328,7 +325,7 @@
                 };
             }
 
-            //test definition => {fn: RegExp/function, cardinality: int, optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
+            //test definition => {fn: RegExp/function, optionality: bool, newBlockMarker: bool, casing: null/upper/lower, def: definitionSymbol, placeholder: placeholder, mask: real maskDefinition}
             function insertTestDefinition(mtoken, element, position) {
                 position = position !== undefined ? position : mtoken.matches.length;
                 var prevMatch = mtoken.matches[position - 1];
@@ -336,7 +333,6 @@
                     if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w]/i.test(element)) || element === ".") {
                         mtoken.matches.splice(position++, 0, {
                             fn: new RegExp(element, opts.casing ? "i" : ""),
-                            cardinality: 1,
                             optionality: mtoken.isOptional,
                             newBlockMarker: prevMatch === undefined || prevMatch.def !== element,
                             casing: null,
@@ -350,7 +346,6 @@
                             prevMatch = mtoken.matches[position - 1];
                             mtoken.matches.splice(position++, 0, {
                                 fn: null,
-                                cardinality: 0,
                                 optionality: mtoken.isOptional,
                                 newBlockMarker: prevMatch === undefined || (prevMatch.def !== lmnt && prevMatch.fn !== null),
                                 casing: null,
@@ -364,32 +359,10 @@
                 } else {
                     var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element];
                     if (maskdef && !escaped) {
-                        var prevalidators = maskdef.prevalidator,
-                            prevalidatorsL = prevalidators ? prevalidators.length : 0;
-                        //handle prevalidators
-                        for (var i = 1; i < maskdef.cardinality; i++) {
-                            var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [],
-                                validator = prevalidator.validator,
-                                cardinality = prevalidator.cardinality;
-                            mtoken.matches.splice(position++, 0, {
-                                fn: validator ? typeof validator === "string" ? new RegExp(validator, opts.casing ? "i" : "") : new function () {
-                                    this.test = validator;
-                                } : new RegExp("."),
-                                cardinality: cardinality ? cardinality : 1,
-                                optionality: mtoken.isOptional,
-                                newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
-                                casing: maskdef.casing,
-                                def: maskdef.definitionSymbol || element,
-                                placeholder: maskdef.placeholder,
-                                nativeDef: element
-                            });
-                            prevMatch = mtoken.matches[position - 1];
-                        }
                         mtoken.matches.splice(position++, 0, {
                             fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function () {
                                 this.test = maskdef.validator;
                             } : new RegExp("."),
-                            cardinality: maskdef.cardinality,
                             optionality: mtoken.isOptional,
                             newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element),
                             casing: maskdef.casing,
@@ -400,7 +373,6 @@
                     } else {
                         mtoken.matches.splice(position++, 0, {
                             fn: null,
-                            cardinality: 0,
                             optionality: mtoken.isOptional,
                             newBlockMarker: prevMatch === undefined || (prevMatch.def !== element && prevMatch.fn !== null),
                             casing: null,
@@ -689,7 +661,8 @@
         SPACE: 32,
         TAB: 9,
         UP: 38,
-        X: 88
+        X: 88,
+        CONTROL: 17
     };
 
     function resolveAlias(aliasStr, options, opts) {
@@ -1046,17 +1019,15 @@
                     //mergelocators for retrieving the correct locator match when merging
                     function setMergeLocators(targetMatch, altMatch) {
                         targetMatch.mloc = targetMatch.mloc || {};
-                        if (targetMatch.mloc[targetMatch.locator[targetMatch.alternation]] === undefined)
-                            targetMatch.mloc[targetMatch.locator[targetMatch.alternation]] = targetMatch.locator.slice();
+                        var locNdx = targetMatch.locator[targetMatch.alternation];
+                        if (typeof locNdx === "string") locNdx = locNdx.split(",")[0];
+                        if (targetMatch.mloc[locNdx] === undefined) targetMatch.mloc[locNdx] = targetMatch.locator.slice();
                         if (altMatch !== undefined) {
-                            var locNdx = altMatch.locator[altMatch.alternation];
-                            if (typeof locNdx === "string")
-                                locNdx = locNdx.split("")[0];
-                            if (targetMatch.mloc[locNdx] === undefined)
-                                targetMatch.mloc[locNdx] = altMatch.mloc[locNdx] || altMatch.locator.slice();
-
-                            targetMatch.locator[targetMatch.alternation] = (altMatch.locator[altMatch.alternation] + "," + targetMatch.locator[targetMatch.alternation]).split(",").sort().join(",");
-                            // targetMatch.alternation = altMatch.alternation; //we pass the alternation index => used in determineLastRequiredPosition
+                            for (var ndx in altMatch.mloc) {
+                                if (typeof ndx === "string") ndx = ndx.split(",")[0];
+                                if (targetMatch.mloc[ndx] === undefined) targetMatch.mloc[ndx] = altMatch.mloc[ndx];
+                            }
+                            targetMatch.locator[targetMatch.alternation] = Object.keys(targetMatch.mloc).join(",");
                         }
                     }
 
@@ -1297,7 +1268,6 @@
                 matches.push({
                     match: {
                         fn: null,
-                        cardinality: 0,
                         optionality: true,
                         casing: null,
                         def: "",
@@ -1321,9 +1291,7 @@
             if (getMaskSet()._buffer === undefined) {
                 //generate template
                 getMaskSet()._buffer = getMaskTemplate(false, 1);
-                if (getMaskSet().buffer === undefined) {
-                    getMaskSet().buffer = getMaskSet()._buffer.slice();
-                }
+                if (getMaskSet().buffer === undefined) getMaskSet().buffer = getMaskSet()._buffer.slice();
             }
             return getMaskSet()._buffer;
         }
@@ -1426,21 +1394,12 @@
             function _isValid(position, c, strict) {
                 var rslt = false;
                 $.each(getTests(position), function (ndx, tst) {
-                    var test = tst.match,
-                        loopend = c ? 1 : 0,
-                        chrs = "";
-                    for (var i = test.cardinality; i > loopend; i--) {
-                        chrs += getBufferElement(position - (i - 1));
-                    }
-                    if (c) {
-                        chrs += c;
-                    }
-
+                    var test = tst.match;
                     //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
+                        test.fn.test(c, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? //non mask
                             {
                                 c: getPlaceholder(position, test, true) || test.def,
                                 pos: position
@@ -2910,9 +2869,9 @@
             function handleCaret(force) {
                 if ((force === true || pos === caretPos.begin) && document.activeElement === input) {
                     if (caretPos.begin === caretPos.end)
-                        maskTemplate += `<span class="im-caret" style="border-right-width: 1px;border-right-style: solid;">`;
+                        maskTemplate += '<span class="im-caret" style="border-right-width: 1px;border-right-style: solid;">';
                     else
-                        maskTemplate += `<span class="im-caret-select">`;
+                        maskTemplate += '<span class="im-caret-select">';
                 }
                 if ((force === true || pos === caretPos.end) && document.activeElement === input) {
                     maskTemplate += "</span>";

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-66",
+  "version": "4.0.0-68",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "index.js",
   "files": [