Browse Source

fix nested alternations

Robin Herbots 9 years ago
parent
commit
af0f6e1243

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.3.4-100",
+  "version": "3.3.4-101",
   "main": [
 	  "./dist/inputmask/inputmask.dependencyLib",
 	  "./dist/inputmask/inputmask",

+ 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.4-100",
+	"version": "3.3.4-101",
 	"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.4-100",
+  "version": "3.3.4-101",
   "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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask.dependencyLib", [ "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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 2 - 12
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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define("inputmask", [ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib")) : factory(window.dependencyLib || jQuery);
@@ -241,17 +241,7 @@
                                         hasMatch || malternateMatches.push(altMatch);
                                     }
                                 }
-                                "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
-                                    if (isFinite(ndx)) {
-                                        var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
-                                        lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
-                                        for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1, 
-                                        mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",", 
-                                        lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]), 
-                                        lmnt.alternation = alternation);
-                                        if (void 0 !== lmnt.locator[alternation]) return lmnt;
-                                    }
-                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
+                                matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
                                 ndxInitializer = ndxInitializerClone.slice();
                             } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;

+ 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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), 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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), 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.4-100
+* Version: 3.3.4-101
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib"), 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.4-100
+* Version: 3.3.4-101
 */
 !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);

+ 2 - 12
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.4-100
+* Version: 3.3.4-101
 */
 !function($) {
     function Inputmask(alias, options) {
@@ -239,17 +239,7 @@
                                         hasMatch || malternateMatches.push(altMatch);
                                     }
                                 }
-                                "string" == typeof altIndex && (malternateMatches = $.map(malternateMatches, function(lmnt, ndx) {
-                                    if (isFinite(ndx)) {
-                                        var mamatch, alternation = lmnt.alternation, altLocArr = lmnt.locator[alternation].toString().split(",");
-                                        lmnt.locator[alternation] = void 0, lmnt.alternation = void 0;
-                                        for (var alndx = 0; alndx < altLocArr.length; alndx++) mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1, 
-                                        mamatch && (void 0 !== lmnt.locator[alternation] ? (lmnt.locator[alternation] += ",", 
-                                        lmnt.locator[alternation] += altLocArr[alndx]) : lmnt.locator[alternation] = parseInt(altLocArr[alndx]), 
-                                        lmnt.alternation = alternation);
-                                        if (void 0 !== lmnt.locator[alternation]) return lmnt;
-                                    }
-                                })), matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
+                                matches = currentMatches.concat(malternateMatches), testPos = pos, insertStop = matches.length > 0, 
                                 ndxInitializer = ndxInitializerClone.slice();
                             } else match = handleMatch(alternateToken.matches[altIndex] || maskToken.matches[altIndex], [ altIndex ].concat(loopNdx), quantifierRecurse);
                             if (match) return !0;

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.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.4-100
+* Version: 3.3.4-101
 */
 !function(a){"function"==typeof define&&define.amd?define("inputmask.dependencyLib",["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

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


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


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


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


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


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


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


+ 34 - 27
js/inputmask.js

@@ -1031,7 +1031,7 @@
 											if (typeof altIndex !== "string" || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) {
 												if (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2)) {
 													hasMatch = altMatch.match.nativeDef === altMatch2.match.nativeDef;
-													// if (altMatch.alternation != altMatch2.alternation){
+													// if (altMatch.alternation != altMatch2.alternation) {
 													// 	console.log("alternation mismatch");
 													// }
 													if (altMatch.alternation == altMatch2.alternation && //can we merge if the alternation is different??  TODO TOCHECK INVESTIGATE
@@ -1053,31 +1053,38 @@
 										}
 									}
 								}
-								if (typeof altIndex == "string") { //filter matches
-									malternateMatches = $.map(malternateMatches, function (lmnt, ndx) {
-										if (isFinite(ndx)) {
-											var mamatch,
-												alternation = lmnt.alternation,
-												altLocArr = lmnt.locator[alternation].toString().split(",");
-											lmnt.locator[alternation] = undefined;
-											lmnt.alternation = undefined;
-
-											for (var alndx = 0; alndx < altLocArr.length; alndx++) {
-												mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1;
-												if (mamatch) { //rebuild the locator with valid entries
-													if (lmnt.locator[alternation] !== undefined) {
-														lmnt.locator[alternation] += ",";
-														lmnt.locator[alternation] += altLocArr[alndx];
-													} else lmnt.locator[alternation] = parseInt(altLocArr[alndx]);
-
-													lmnt.alternation = alternation;
-												}
-											}
-
-											if (lmnt.locator[alternation] !== undefined) return lmnt;
-										}
-									});
-								}
+								// if (typeof altIndex == "string") { //filter matches
+								// 	var maltCount = malternateMatches.length;
+								// 	malternateMatches = $.map(malternateMatches, function (lmnt, ndx) {
+								// 		if (isFinite(ndx)) {
+								// 			var originalalt = lmnt.alternation;
+								// 			var mamatch,
+								// 				alternation = lmnt.alternation,
+								// 				altLocArr = lmnt.locator[alternation].toString().split(",");
+								// 			lmnt.locator[alternation] = undefined;
+								// 			lmnt.alternation = undefined;
+                                //
+								// 			for (var alndx = 0; alndx < altLocArr.length; alndx++) {
+								// 				mamatch = $.inArray(altLocArr[alndx], altIndexArr) !== -1;
+								// 				if (mamatch) { //rebuild the locator with valid entries
+								// 					if (lmnt.locator[alternation] !== undefined) {
+								// 						lmnt.locator[alternation] += ",";
+								// 						lmnt.locator[alternation] += altLocArr[alndx];
+								// 					} else lmnt.locator[alternation] = parseInt(altLocArr[alndx]);
+                                //
+								// 					lmnt.alternation = alternation;
+								// 					if (originalalt !== lmnt.alternation)
+								// 						alert("new " + lmnt.alternation);
+								// 				}
+								// 			}
+                                //
+								// 			if (lmnt.locator[alternation] !== undefined) return lmnt;
+								// 		}
+								// 	});
+								// 	maltCount2 = malternateMatches.length;
+								// 	if (maltCount.length !== maltCount2.length)
+								// 		alert(maltCount + " vs " + maltCount2);
+								// }
 
 								matches = currentMatches.concat(malternateMatches);
 								testPos = pos;
@@ -1216,7 +1223,7 @@
 				return filterTests($.extend(true, [], matches));
 			}
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
-			//console.log(pos + " - " + JSON.stringify(matches));
+			// console.log(pos + " - " + JSON.stringify(matches));
 			return filterTests(getMaskSet().tests[pos]);
 		}
 

+ 2 - 2
js/inputmask.phone.extensions.js

@@ -46,7 +46,7 @@
 				masks.splice(i, 1);
 			}
 			for (var ndx in maskGroup) {
-				if (maskGroup[ndx].length > 1000) {
+				if (maskGroup[ndx].length > 500) {
 					reduceVariations(maskGroup[ndx].slice(), ndx, maskGroup);
 				}
 			}
@@ -74,7 +74,7 @@
 		}
 
 
-		if (opts.phoneCodes && opts.phoneCodes.length > 2000) {
+		if (opts.phoneCodes && opts.phoneCodes.length > 1000) {
 			mask = mask.substr(1, mask.length - 2);
 			reduceVariations(mask.split(opts.groupmarker.end + opts.alternatormarker + opts.groupmarker.start));
 			mask = rebuild(maskGroups);

+ 1 - 1
package.json

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

+ 3 - 3
qunit/main_phone.js

@@ -1,8 +1,8 @@
 define([
 	"qunit",
-	// "tests_phone_world",
-	// "tests_phonebe",
-	// "tests_phonenl",
+	"tests_phone_world",
+	"tests_phonebe",
+	"tests_phonenl",
 	"tests_phoneru"
 ], function(qunit) {
 	qunit.load();