Browse Source

Multiple alternators fix #1553

Robin Herbots 8 years ago
parent
commit
09ebbd3616
47 changed files with 176 additions and 73 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      app.js
  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. 1 1
      dist/inputmask/inputmask.extensions.js
  14. 7 6
      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/inputmask.regex.extensions.js
  18. 1 1
      dist/inputmask/jquery.inputmask.js
  19. 1 1
      dist/inputmask/phone-codes/phone-be.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.js
  24. 7 6
      dist/jquery.inputmask.bundle.js
  25. 1 1
      dist/min/inputmask/bindings/inputmask.binding.min.js
  26. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js
  27. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js
  28. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js
  29. 1 1
      dist/min/inputmask/global/document.min.js
  30. 1 1
      dist/min/inputmask/global/window.min.js
  31. 1 1
      dist/min/inputmask/inputmask.date.extensions.min.js
  32. 1 1
      dist/min/inputmask/inputmask.extensions.min.js
  33. 3 3
      dist/min/inputmask/inputmask.min.js
  34. 1 1
      dist/min/inputmask/inputmask.numeric.extensions.min.js
  35. 1 1
      dist/min/inputmask/inputmask.phone.extensions.min.js
  36. 1 1
      dist/min/inputmask/inputmask.regex.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-nl.min.js
  40. 1 1
      dist/min/inputmask/phone-codes/phone-ru.min.js
  41. 1 1
      dist/min/inputmask/phone-codes/phone-uk.min.js
  42. 1 1
      dist/min/inputmask/phone-codes/phone.min.js
  43. 4 4
      dist/min/jquery.inputmask.bundle.min.js
  44. 3 1
      index.html
  45. 17 15
      js/inputmask.js
  46. 1 1
      package.json
  47. 95 0
      qunit/tests_alternations.js

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
 	- initialization
 
 ### Fixed
+- Multiple alternators #1553
 - Weird Issue with decimal masking when value is like 0.55 #1512
 - IE 8 problems with currency and jquery.inputmask.bundle.js #1545
 - Rounding error for numeric aliases #1300

+ 1 - 0
app.js

@@ -1,4 +1,5 @@
 //webpack test
+import "./css/inputmask.css";
 import im from "./index";
 
 //just for testing

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.5-214",
+  "version": "3.3.5-221",
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.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.5-214",
+	"version": "3.3.5-221",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 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.5-214",
+  "version": "3.3.5-221",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 7 - 6
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-214
+* Version: 3.3.5-221
 */
 
 !function(factory) {
@@ -195,9 +195,10 @@
                                                 if (function(source, target) {
                                                     return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
                                                 }(altMatch, altMatch2)) {
-                                                    dropMatch = altMatch.match.nativeDef === altMatch2.match.nativeDef, altMatch.alternation == altMatch2.alternation && -1 === altMatch2.locator[altMatch2.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch2.alternation] = altMatch2.locator[altMatch2.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                    altMatch2.alternation = altMatch.alternation, null == altMatch.match.fn && (altMatch2.na = altMatch2.na || altMatch.locator[altMatch.alternation].toString(), 
-                                                    -1 === altMatch2.na.indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.na = altMatch2.na + "," + altMatch.locator[altMatch.alternation])));
+                                                    console.log("case 5"), altMatch.alternation == altMatch2.alternation && -1 === altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na || altMatch.locator[altMatch.alternation].toString(), 
+                                                    -1 === altMatch.na.indexOf(altMatch.locator[altMatch.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na + "," + altMatch.locator[altMatch2.alternation].toString().split("")[0]), 
+                                                    dropMatch = !0, altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation].toString().split("")[0] + "," + altMatch.locator[altMatch.alternation], 
+                                                    malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch));
                                                     break;
                                                 }
                                             }
@@ -443,7 +444,7 @@
                             altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                             for (var mndx = 0; mndx < altNdxs.length; mndx++) {
                                 var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
-                                if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")))) {
+                                if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")) || -1 === $.inArray(decisionTaker.toString(), altNdxs))) {
                                     getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                     var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                     for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
@@ -717,7 +718,7 @@
             var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
             input.parentNode;
             colorMask = document.createElement("div"), document.body.appendChild(colorMask);
-            for (var style in computedStyle) isNaN(style) && "cssText" !== style && -1 == style.indexOf("webkit") && (colorMask.style[style] = computedStyle[style]);
+            for (var style in computedStyle) computedStyle.hasOwnProperty(style) && isNaN(style) && "cssText" !== style && -1 == style.indexOf("webkit") && (colorMask.style[style] = computedStyle[style]);
             input.style.backgroundColor = "transparent", input.style.color = "transparent", 
             input.style.webkitAppearance = "caret", input.style.mozAppearance = "caret", input.style.Appearance = "caret", 
             position(), $(window).on("resize", function(e) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 7 - 6
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-214
+* Version: 3.3.5-221
 */
 
 !function(factory) {
@@ -194,9 +194,10 @@
                                                     if (function(source, target) {
                                                         return null === source.match.fn && null !== target.match.fn && target.match.fn.test(source.match.def, getMaskSet(), pos, !1, opts, !1);
                                                     }(altMatch, altMatch2)) {
-                                                        dropMatch = altMatch.match.nativeDef === altMatch2.match.nativeDef, altMatch.alternation == altMatch2.alternation && -1 === altMatch2.locator[altMatch2.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.locator[altMatch2.alternation] = altMatch2.locator[altMatch2.alternation] + "," + altMatch.locator[altMatch.alternation], 
-                                                        altMatch2.alternation = altMatch.alternation, null == altMatch.match.fn && (altMatch2.na = altMatch2.na || altMatch.locator[altMatch.alternation].toString(), 
-                                                        -1 === altMatch2.na.indexOf(altMatch.locator[altMatch.alternation]) && (altMatch2.na = altMatch2.na + "," + altMatch.locator[altMatch.alternation])));
+                                                        console.log("case 5"), altMatch.alternation == altMatch2.alternation && -1 === altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na || altMatch.locator[altMatch.alternation].toString(), 
+                                                        -1 === altMatch.na.indexOf(altMatch.locator[altMatch.alternation].toString().split("")[0]) && (altMatch.na = altMatch.na + "," + altMatch.locator[altMatch2.alternation].toString().split("")[0]), 
+                                                        dropMatch = !0, altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation].toString().split("")[0] + "," + altMatch.locator[altMatch.alternation], 
+                                                        malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch));
                                                         break;
                                                     }
                                                 }
@@ -442,7 +443,7 @@
                                 altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                                 for (var mndx = 0; mndx < altNdxs.length; mndx++) {
                                     var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
-                                    if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")))) {
+                                    if (decisionTaker < altNdxs[mndx] && (test.na === undefined || -1 === $.inArray(altNdxs[mndx], test.na.split(",")) || -1 === $.inArray(decisionTaker.toString(), altNdxs))) {
                                         getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                         var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                         for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
@@ -716,7 +717,7 @@
                 var offset = $(input).position(), computedStyle = (input.ownerDocument.defaultView || window).getComputedStyle(input, null);
                 input.parentNode;
                 colorMask = document.createElement("div"), document.body.appendChild(colorMask);
-                for (var style in computedStyle) isNaN(style) && "cssText" !== style && -1 == style.indexOf("webkit") && (colorMask.style[style] = computedStyle[style]);
+                for (var style in computedStyle) computedStyle.hasOwnProperty(style) && isNaN(style) && "cssText" !== style && -1 == style.indexOf("webkit") && (colorMask.style[style] = computedStyle[style]);
                 input.style.backgroundColor = "transparent", input.style.color = "transparent", 
                 input.style.webkitAppearance = "caret", input.style.mozAppearance = "caret", input.style.Appearance = "caret", 
                 position(), $(window).on("resize", function(e) {

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/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-214
+* Version: 3.3.5-221
 */
 
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):window.dependencyLib=a(jQuery)}(function(a){return a});

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/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-214
+* Version: 3.3.5-221
 */
 
 "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/jquery.inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.5-214
+* Version: 3.3.5-221
 */
 
 "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
+ 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
+ 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-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.min.js


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


+ 3 - 1
index.html

@@ -9,7 +9,9 @@
 <br/>
 <script type="text/javascript" src="build/bundle.js" charset="utf-8"></script>
 <script>
-	Inputmask("currency").mask("test1");
+	Inputmask("currency", {
+	    colorMask: true
+	}).mask("test1");
 </script>
 </body>
 </html>

+ 17 - 15
js/inputmask.js

@@ -1077,17 +1077,18 @@
 													dropMatch = false;
 													break;
 												} else if (staticCanMatchDefinition(altMatch, altMatch2)) {
-													// console.log("case 5");
-													dropMatch = altMatch.match.nativeDef === altMatch2.match.nativeDef;
-													if (altMatch.alternation == altMatch2.alternation && //can we merge if the alternation is different??  TODO TOCHECK INVESTIGATE
-														altMatch2.locator[altMatch2.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1) {
-														altMatch2.locator[altMatch2.alternation] = altMatch2.locator[altMatch2.alternation] + "," + altMatch.locator[altMatch.alternation];
-														altMatch2.alternation = altMatch.alternation; //we pass the alternation index => used in determineLastRequiredPosition
-														if (altMatch.match.fn == null) { //staticCanMatchDefinition => set no alternate on match
-															altMatch2.na = altMatch2.na || altMatch.locator[altMatch.alternation].toString();
-															if (altMatch2.na.indexOf(altMatch.locator[altMatch.alternation]) === -1)
-																altMatch2.na = altMatch2.na + "," + altMatch.locator[altMatch.alternation];
-														}
+													console.log("case 5");
+													if (altMatch.alternation == altMatch2.alternation &&
+														altMatch.locator[altMatch.alternation].toString().indexOf(altMatch2.locator[altMatch2.alternation].toString().split("")[0]) === -1) {
+
+														//no alternation marker
+														altMatch.na = altMatch.na || altMatch.locator[altMatch.alternation].toString();
+														if (altMatch.na.indexOf(altMatch.locator[altMatch.alternation].toString().split("")[0]) === -1)
+															altMatch.na = altMatch.na + "," + altMatch.locator[altMatch2.alternation].toString().split("")[0];
+														//insert match above general match
+														dropMatch = true;
+														altMatch.locator[altMatch.alternation] = altMatch2.locator[altMatch2.alternation].toString().split("")[0] + "," + altMatch.locator[altMatch.alternation];
+														malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch);
 													}
 													break;
 												}
@@ -1488,7 +1489,7 @@
 								staticInputsBeforePos = 0,
 								staticInputsBeforePosAlternate = 0,
 								verifyValidInput = false;
-							if (decisionTaker < altNdxs[mndx] && (test.na === undefined || $.inArray(altNdxs[mndx], test.na.split(",")) === -1)) {
+							if (decisionTaker < altNdxs[mndx] && (test.na === undefined || ($.inArray(altNdxs[mndx], test.na.split(",")) === -1 || $.inArray(decisionTaker.toString(), altNdxs) === -1))) {
 								getMaskSet().validPositions[decisionPos] = $.extend(true, {}, test);
 								var possibilities = getMaskSet().validPositions[decisionPos].locator;
 								getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]); //set forced decision
@@ -2764,9 +2765,10 @@
 			colorMask = document.createElement("div");
 			document.body.appendChild(colorMask); //insert at body to prevent css clash :last-child for example
 			for (var style in computedStyle) { //clone styles
-				if (isNaN(style) && style !== "cssText" && style.indexOf("webkit") == -1) {
-					colorMask.style[style] = computedStyle[style];
-				}
+				if (computedStyle.hasOwnProperty(style))
+					if (isNaN(style) && style !== "cssText" && style.indexOf("webkit") == -1) {
+						colorMask.style[style] = computedStyle[style];
+					}
 			}
 
 			//restyle input

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.5-214",
+  "version": "3.3.5-221",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "index.js",
   "files": [

+ 95 - 0
qunit/tests_alternations.js

@@ -224,4 +224,99 @@ define([
 		$("#testmask").Type("a1");
 		assert.equal(testmask.inputmask._valueGet(), "a1", "Result " + testmask.inputmask._valueGet());
 	});
+
+	qunit.test("(999)|(0aa) - type 0ab - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(999)|(0aa)").mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("0ab");
+		assert.equal(testmask.inputmask._valueGet(), "0ab", "Result " + testmask.inputmask._valueGet());
+	});
+
+	qunit.test("(999)|(0aa) - type 1ab - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(999)|(0aa)").mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("1ab");
+		assert.equal(testmask.inputmask._valueGet(), "1__", "Result " + testmask.inputmask._valueGet());
+	});
+
+	qunit.test("(9)|(09)|(19)|(2f) - type 41 - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(9)|(09)|(19)|(2f)", {
+			definitions: {
+				"f": {validator: "[0-3]"}
+			}
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("41");
+		assert.equal(testmask.inputmask._valueGet(), "4", "Result " + testmask.inputmask._valueGet());
+	});
+
+	qunit.test("(9)|(09)|(19)|(2f) - type 01 - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(9)|(09)|(19)|(2f)", {
+			definitions: {
+				"f": {validator: "[0-3]"}
+			}
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("01");
+		assert.equal(testmask.inputmask._valueGet(), "01", "Result " + testmask.inputmask._valueGet());
+	});
+	qunit.test("(9)|(09)|(19)|(2f) - type 11 - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(9)|(09)|(19)|(2f)", {
+			definitions: {
+				"f": {validator: "[0-3]"}
+			}
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("11");
+		assert.equal(testmask.inputmask._valueGet(), "11", "Result " + testmask.inputmask._valueGet());
+	});
+
+	qunit.test("(9)|(09)|(19)|(2f) - type 23 - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(9)|(09)|(19)|(2f)", {
+			definitions: {
+				"f": {validator: "[0-3]"}
+			}
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("23");
+		assert.equal(testmask.inputmask._valueGet(), "23", "Result " + testmask.inputmask._valueGet());
+	});
+	qunit.test("(9)|(09)|(19)|(2f) - type 24 - ivaninDarpatov", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("(9)|(09)|(19)|(2f)", {
+			definitions: {
+				"f": {validator: "[0-3]"}
+			}
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("24");
+		assert.equal(testmask.inputmask._valueGet(), "2_", "Result " + testmask.inputmask._valueGet());
+	});
 });