Robin Herbots 10 年之前
父节点
当前提交
8e5f426517

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
 - Update placeholder handling
 
 ### Fixed
+- Escape optional marker, quantifiable marker, alternator marker and backslash not working #930
 - Is numeric carret position broken? #928
 - Decimal looses digits #924
 - Firefox: cursor jumps to the right when clicking anywhere on the value #921

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.1.64-76",
+  "version": "3.1.64-77",
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.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.1.64-76",
+    "version": "3.1.64-77",
     "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.1.64-76",
+	"version": "3.1.64-77",
     "type": "library",
     "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
     "homepage": "http://robinherbots.github.io/jquery.inputmask",

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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/inputmask.date.extensions.min.js


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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/inputmask.extensions.min.js


+ 11 - 10
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-76
+* Version: 3.1.64-77
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);
@@ -99,13 +99,13 @@
                     mask: element
                 }), escaped = !1;
             }
-            function maskStaticGroupMarker(lastMatch) {
+            function verifyGroupMarker(lastMatch) {
                 lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0), 
                 insertTestDefinition(lastMatch, opts.groupmarker.end));
             }
-            function maskCurrentToken(m, currentToken, lastMatch) {
-                currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
-                maskStaticGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
+            function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
+                currentToken.matches.length > 0 && (void 0 == extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
+                verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
             }
             for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new maskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) if (m = match[0], 
             escaped) maskCurrentToken(m, currentToken, lastMatch); else switch (m.charAt(0)) {
@@ -166,8 +166,7 @@
 
               default:
                 if (openenings.length > 0) {
-                    if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.length > 0 && !currentOpeningToken.isAlternator && (lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1], 
-                    maskStaticGroupMarker(lastMatch)), insertTestDefinition(currentOpeningToken, m), 
+                    if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator), 
                     currentOpeningToken.isAlternator) {
                         alternator = openenings.pop();
                         for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
@@ -177,7 +176,7 @@
                 } else maskCurrentToken(m, currentToken, lastMatch);
             }
             return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
-            maskStaticGroupMarker(lastMatch), maskTokens.push(currentToken)), maskTokens;
+            verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), maskTokens;
         }
         function generateMask(mask, metadata) {
             if (void 0 == mask || "" == mask) return void 0;
@@ -735,8 +734,10 @@
         function isComplete(buffer) {
             if ($.isFunction(opts.isComplete)) return opts.isComplete.call($el, buffer, opts);
             if ("*" == opts.repeat) return void 0;
-            var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
-            getLastValidPosition();
+            {
+                var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
+                getLastValidPosition();
+            }
             if (void 0 == lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
                 complete = !0;
                 for (var i = 0; aml >= i; i++) {

文件差异内容过多而无法显示
+ 2 - 2
dist/inputmask/inputmask.min.js


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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.min.js


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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/inputmask.phone.extensions.min.js


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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/inputmask.regex.extensions.min.js


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

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

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.min.js


+ 11 - 10
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-76
+* Version: 3.1.64-77
 */
 !function($) {
     function inputmask(options) {
@@ -97,13 +97,13 @@
                     mask: element
                 }), escaped = !1;
             }
-            function maskStaticGroupMarker(lastMatch) {
+            function verifyGroupMarker(lastMatch) {
                 lastMatch.isGroup && (lastMatch.isGroup = !1, insertTestDefinition(lastMatch, opts.groupmarker.start, 0), 
                 insertTestDefinition(lastMatch, opts.groupmarker.end));
             }
-            function maskCurrentToken(m, currentToken, lastMatch) {
-                currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
-                maskStaticGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
+            function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
+                currentToken.matches.length > 0 && (void 0 == extraCondition || extraCondition) && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
+                verifyGroupMarker(lastMatch)), insertTestDefinition(currentToken, m);
             }
             for (var match, m, openingToken, currentOpeningToken, alternator, lastMatch, tokenizer = /(?:[?*+]|\{[0-9\+\*]+(?:,[0-9\+\*]*)?\})\??|[^.?*+^${[]()|\\]+|./g, escaped = !1, currentToken = new maskToken(), openenings = [], maskTokens = []; match = tokenizer.exec(mask); ) if (m = match[0], 
             escaped) maskCurrentToken(m, currentToken, lastMatch); else switch (m.charAt(0)) {
@@ -164,8 +164,7 @@
 
               default:
                 if (openenings.length > 0) {
-                    if (currentOpeningToken = openenings[openenings.length - 1], currentOpeningToken.matches.length > 0 && !currentOpeningToken.isAlternator && (lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1], 
-                    maskStaticGroupMarker(lastMatch)), insertTestDefinition(currentOpeningToken, m), 
+                    if (currentOpeningToken = openenings[openenings.length - 1], maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator), 
                     currentOpeningToken.isAlternator) {
                         alternator = openenings.pop();
                         for (var mndx = 0; mndx < alternator.matches.length; mndx++) alternator.matches[mndx].isGroup = !1;
@@ -175,7 +174,7 @@
                 } else maskCurrentToken(m, currentToken, lastMatch);
             }
             return currentToken.matches.length > 0 && (lastMatch = currentToken.matches[currentToken.matches.length - 1], 
-            maskStaticGroupMarker(lastMatch), maskTokens.push(currentToken)), maskTokens;
+            verifyGroupMarker(lastMatch), maskTokens.push(currentToken)), maskTokens;
         }
         function generateMask(mask, metadata) {
             if (void 0 == mask || "" == mask) return void 0;
@@ -733,8 +732,10 @@
         function isComplete(buffer) {
             if ($.isFunction(opts.isComplete)) return opts.isComplete.call($el, buffer, opts);
             if ("*" == opts.repeat) return void 0;
-            var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
-            getLastValidPosition();
+            {
+                var complete = !1, lrp = determineLastRequiredPosition(!0), aml = seekPrevious(lrp.l);
+                getLastValidPosition();
+            }
             if (void 0 == lrp.def || lrp.def.newBlockMarker || lrp.def.optionality || lrp.def.optionalQuantifier) {
                 complete = !0;
                 for (var i = 0; aml >= i; i++) {

文件差异内容过多而无法显示
+ 2 - 2
dist/jquery.inputmask.bundle.min.js


+ 7 - 11
js/inputmask.js

@@ -400,7 +400,7 @@
 				}
 			}
 
-			function maskStaticGroupMarker(lastMatch){
+			function verifyGroupMarker(lastMatch) {
 				if (lastMatch["isGroup"]) { //this is not a group but a normal mask => convert
 					lastMatch.isGroup = false;
 					insertTestDefinition(lastMatch, opts.groupmarker.start, 0);
@@ -408,10 +408,10 @@
 				}
 			}
 
-			function maskCurrentToken(m, currentToken, lastMatch){
-				if (currentToken.matches.length > 0) {
+			function maskCurrentToken(m, currentToken, lastMatch, extraCondition) {
+				if (currentToken.matches.length > 0 && (extraCondition == undefined || extraCondition)) {
 					lastMatch = currentToken.matches[currentToken.matches.length - 1];
-					maskStaticGroupMarker(lastMatch);
+					verifyGroupMarker(lastMatch);
 				}
 				insertTestDefinition(currentToken, m);
 			}
@@ -428,7 +428,7 @@
 
 			while (match = tokenizer.exec(mask)) {
 				m = match[0];
-				if(escaped){
+				if (escaped) {
 					maskCurrentToken(m, currentToken, lastMatch);
 					continue;
 				}
@@ -523,11 +523,7 @@
 					default:
 						if (openenings.length > 0) {
 							currentOpeningToken = openenings[openenings.length - 1];
-							if (currentOpeningToken.matches.length > 0 && !currentOpeningToken.isAlternator) {
-								lastMatch = currentOpeningToken.matches[currentOpeningToken.matches.length - 1];
-								maskStaticGroupMarker(lastMatch);
-							}
-							insertTestDefinition(currentOpeningToken, m);
+							maskCurrentToken(m, currentOpeningToken, lastMatch, !currentOpeningToken.isAlternator);
 							if (currentOpeningToken.isAlternator) { //handle alternator a | b case
 								alternator = openenings.pop();
 								for (var mndx = 0; mndx < alternator.matches.length; mndx++) {
@@ -548,7 +544,7 @@
 
 			if (currentToken.matches.length > 0) {
 				lastMatch = currentToken.matches[currentToken.matches.length - 1];
-				maskStaticGroupMarker(lastMatch);
+				verifyGroupMarker(lastMatch);
 				maskTokens.push(currentToken);
 			}
 

+ 1 - 1
package.json

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