Browse Source

Update tokenmatch for long datetimes #2751

Robin Herbots 2 years ago
parent
commit
f96be35fc4

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.52",
+  "version": "5.0.9-beta.53",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 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": "5.0.9-beta.52",
+  "version": "5.0.9-beta.53",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 15 - 11
dist/colormask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.9-beta.52
+ * Version: 5.0.9-beta.53
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1175,8 +1175,8 @@
                             for (P(t).lastIndex = 0; i = P(t).exec(this.format); ) {
                                 var a = new RegExp("\\d+$").exec(i[0]), r = a ? i[0][0] + "x" : i[0], o = void 0;
                                 if (void 0 !== e) {
-                                    if (console.log("mask", e), a) {
-                                        var s = P(t).lastIndex, c = j(i.index, t, n && n.maskset);
+                                    if (a) {
+                                        var s = P(t).lastIndex, c = j.call(n, i.index, t, n && n.maskset);
                                         P(t).lastIndex = s, o = e.slice(0, e.indexOf(c.nextMatch[0]));
                                     } else {
                                         for (var u = i[0][0], f = i.index; n && l.getTest.call(n, f).match.placeholder === u; ) f++;
@@ -1355,7 +1355,7 @@
                     if (!g) return !0;
                     if (void 0 === e.rawday || !isFinite(e.rawday) && new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day || "29" == e.day && (!isFinite(e.rawyear) || void 0 === e.rawyear || "" === e.rawyear) || new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day) return t;
                     if ("29" == e.day) {
-                        var i = j(t.pos, n, this.maskset);
+                        var i = j.call(this, t.pos, n, this.maskset);
                         if (i.targetMatch && "yyyy" === i.targetMatch[0] && t.pos - i.targetMatchIndex == 2) return t.remove = t.pos + 1, 
                         t;
                     } else if (2 == e.date.getMonth() && "30" == e.day && void 0 !== t.c) return e.day = "03", 
@@ -1400,16 +1400,20 @@
                     }, t);
                 }
                 function j(e, t, n) {
-                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, l = 0;
+                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, s = 0;
                     for (P(t).lastIndex = 0; a = P(t).exec(t.inputFormat); ) {
-                        var s = new RegExp("\\d+$").exec(a[0]);
-                        if (o += l = s ? parseInt(s[0]) : a[0].length, -1 != a[0].indexOf(r) || o >= e + 1) {
+                        var c = new RegExp("\\d+$").exec(a[0]);
+                        if (c) s = parseInt(c[0]); else {
+                            for (var u = a[0][0], f = o; this && l.getTest.call(this, f).match.placeholder === u; ) f++;
+                            0 === (s = f - o) && (s = a[0].length);
+                        }
+                        if (o += s, -1 != a[0].indexOf(r) || o >= e + 1) {
                             i = a, a = P(t).exec(t.inputFormat);
                             break;
                         }
                     }
                     return {
-                        targetMatchIndex: o - l,
+                        targetMatchIndex: o - s,
                         nextMatch: a,
                         targetMatch: i
                     };
@@ -1432,7 +1436,7 @@
                         preValidation: function(e, t, n, i, a, r, o, l) {
                             if (l) return !0;
                             if (isNaN(n) && e[t] !== n) {
-                                var s = j(t, a);
+                                var s = j.call(this, t, a, r);
                                 if (s.nextMatch && s.nextMatch[0] === n && s.targetMatch[0].length > 1) {
                                     var c = w(s.targetMatch)[0];
                                     if (new RegExp(c).test("0" + e[t - 1])) return e[t] = e[t - 1], e[t - 1] = "0", 
@@ -1452,7 +1456,7 @@
                         postValidation: function(e, t, n, i, a, r, o, s) {
                             var c, u, f = this;
                             if (o) return !0;
-                            if (!1 === i && (((c = j(t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j(t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
+                            if (!1 === i && (((c = j.call(f, t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j.call(f, t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
                             void 0 !== u && (void 0 !== r.validPositions[t + 1] && new RegExp(u).test(n + "0") ? (e[t] = n, 
                             e[t + 1] = "0", i = {
                                 pos: t + 2,
@@ -1460,7 +1464,7 @@
                             }) : new RegExp(u).test("0" + n) && (e[t] = "0", e[t + 1] = n, i = {
                                 pos: t + 2
                             })), !1 === i)) return i;
-                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j(t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
+                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j.call(f, t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
                                 var p = w(c.targetMatch);
                                 u = p[0];
                                 var d = e.slice(c.targetMatchIndex, c.targetMatchIndex + c.targetMatch[0].length);

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


+ 15 - 11
dist/inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.9-beta.52
+ * Version: 5.0.9-beta.53
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1060,8 +1060,8 @@
                             for (P(t).lastIndex = 0; i = P(t).exec(this.format); ) {
                                 var a = new RegExp("\\d+$").exec(i[0]), r = a ? i[0][0] + "x" : i[0], o = void 0;
                                 if (void 0 !== e) {
-                                    if (console.log("mask", e), a) {
-                                        var s = P(t).lastIndex, c = j(i.index, t, n && n.maskset);
+                                    if (a) {
+                                        var s = P(t).lastIndex, c = j.call(n, i.index, t, n && n.maskset);
                                         P(t).lastIndex = s, o = e.slice(0, e.indexOf(c.nextMatch[0]));
                                     } else {
                                         for (var u = i[0][0], f = i.index; n && l.getTest.call(n, f).match.placeholder === u; ) f++;
@@ -1240,7 +1240,7 @@
                     if (!g) return !0;
                     if (void 0 === e.rawday || !isFinite(e.rawday) && new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day || "29" == e.day && (!isFinite(e.rawyear) || void 0 === e.rawyear || "" === e.rawyear) || new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day) return t;
                     if ("29" == e.day) {
-                        var i = j(t.pos, n, this.maskset);
+                        var i = j.call(this, t.pos, n, this.maskset);
                         if (i.targetMatch && "yyyy" === i.targetMatch[0] && t.pos - i.targetMatchIndex == 2) return t.remove = t.pos + 1, 
                         t;
                     } else if (2 == e.date.getMonth() && "30" == e.day && void 0 !== t.c) return e.day = "03", 
@@ -1285,16 +1285,20 @@
                     }, t);
                 }
                 function j(e, t, n) {
-                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, l = 0;
+                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, s = 0;
                     for (P(t).lastIndex = 0; a = P(t).exec(t.inputFormat); ) {
-                        var s = new RegExp("\\d+$").exec(a[0]);
-                        if (o += l = s ? parseInt(s[0]) : a[0].length, -1 != a[0].indexOf(r) || o >= e + 1) {
+                        var c = new RegExp("\\d+$").exec(a[0]);
+                        if (c) s = parseInt(c[0]); else {
+                            for (var u = a[0][0], f = o; this && l.getTest.call(this, f).match.placeholder === u; ) f++;
+                            0 === (s = f - o) && (s = a[0].length);
+                        }
+                        if (o += s, -1 != a[0].indexOf(r) || o >= e + 1) {
                             i = a, a = P(t).exec(t.inputFormat);
                             break;
                         }
                     }
                     return {
-                        targetMatchIndex: o - l,
+                        targetMatchIndex: o - s,
                         nextMatch: a,
                         targetMatch: i
                     };
@@ -1317,7 +1321,7 @@
                         preValidation: function(e, t, n, i, a, r, o, l) {
                             if (l) return !0;
                             if (isNaN(n) && e[t] !== n) {
-                                var s = j(t, a);
+                                var s = j.call(this, t, a, r);
                                 if (s.nextMatch && s.nextMatch[0] === n && s.targetMatch[0].length > 1) {
                                     var c = w(s.targetMatch)[0];
                                     if (new RegExp(c).test("0" + e[t - 1])) return e[t] = e[t - 1], e[t - 1] = "0", 
@@ -1337,7 +1341,7 @@
                         postValidation: function(e, t, n, i, a, r, o, s) {
                             var c, u, f = this;
                             if (o) return !0;
-                            if (!1 === i && (((c = j(t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j(t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
+                            if (!1 === i && (((c = j.call(f, t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j.call(f, t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
                             void 0 !== u && (void 0 !== r.validPositions[t + 1] && new RegExp(u).test(n + "0") ? (e[t] = n, 
                             e[t + 1] = "0", i = {
                                 pos: t + 2,
@@ -1345,7 +1349,7 @@
                             }) : new RegExp(u).test("0" + n) && (e[t] = "0", e[t + 1] = n, i = {
                                 pos: t + 2
                             })), !1 === i)) return i;
-                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j(t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
+                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j.call(f, t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
                                 var p = w(c.targetMatch);
                                 u = p[0];
                                 var d = e.slice(c.targetMatchIndex, c.targetMatchIndex + c.targetMatch[0].length);

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


+ 15 - 11
dist/jquery.inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.9-beta.52
+ * Version: 5.0.9-beta.53
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(require("jquery")); else if ("function" == typeof define && define.amd) define([ "jquery" ], t); else {
@@ -889,8 +889,8 @@
                             for (P(t).lastIndex = 0; i = P(t).exec(this.format); ) {
                                 var a = new RegExp("\\d+$").exec(i[0]), r = a ? i[0][0] + "x" : i[0], o = void 0;
                                 if (void 0 !== e) {
-                                    if (console.log("mask", e), a) {
-                                        var l = P(t).lastIndex, c = j(i.index, t, n && n.maskset);
+                                    if (a) {
+                                        var l = P(t).lastIndex, c = j.call(n, i.index, t, n && n.maskset);
                                         P(t).lastIndex = l, o = e.slice(0, e.indexOf(c.nextMatch[0]));
                                     } else {
                                         for (var u = i[0][0], f = i.index; n && s.getTest.call(n, f).match.placeholder === u; ) f++;
@@ -1069,7 +1069,7 @@
                     if (!g) return !0;
                     if (void 0 === e.rawday || !isFinite(e.rawday) && new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day || "29" == e.day && (!isFinite(e.rawyear) || void 0 === e.rawyear || "" === e.rawyear) || new Date(e.date.getFullYear(), isFinite(e.rawmonth) ? e.month : e.date.getMonth() + 1, 0).getDate() >= e.day) return t;
                     if ("29" == e.day) {
-                        var i = j(t.pos, n, this.maskset);
+                        var i = j.call(this, t.pos, n, this.maskset);
                         if (i.targetMatch && "yyyy" === i.targetMatch[0] && t.pos - i.targetMatchIndex == 2) return t.remove = t.pos + 1, 
                         t;
                     } else if (2 == e.date.getMonth() && "30" == e.day && void 0 !== t.c) return e.day = "03", 
@@ -1114,16 +1114,20 @@
                     }, t);
                 }
                 function j(e, t, n) {
-                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, s = 0;
+                    var i, a, r = n && n.tests[e] ? n.tests[e][0].match.placeholder : "", o = 0, l = 0;
                     for (P(t).lastIndex = 0; a = P(t).exec(t.inputFormat); ) {
-                        var l = new RegExp("\\d+$").exec(a[0]);
-                        if (o += s = l ? parseInt(l[0]) : a[0].length, -1 != a[0].indexOf(r) || o >= e + 1) {
+                        var c = new RegExp("\\d+$").exec(a[0]);
+                        if (c) l = parseInt(c[0]); else {
+                            for (var u = a[0][0], f = o; this && s.getTest.call(this, f).match.placeholder === u; ) f++;
+                            0 === (l = f - o) && (l = a[0].length);
+                        }
+                        if (o += l, -1 != a[0].indexOf(r) || o >= e + 1) {
                             i = a, a = P(t).exec(t.inputFormat);
                             break;
                         }
                     }
                     return {
-                        targetMatchIndex: o - s,
+                        targetMatchIndex: o - l,
                         nextMatch: a,
                         targetMatch: i
                     };
@@ -1146,7 +1150,7 @@
                         preValidation: function(e, t, n, i, a, r, o, s) {
                             if (s) return !0;
                             if (isNaN(n) && e[t] !== n) {
-                                var l = j(t, a);
+                                var l = j.call(this, t, a, r);
                                 if (l.nextMatch && l.nextMatch[0] === n && l.targetMatch[0].length > 1) {
                                     var c = w(l.targetMatch)[0];
                                     if (new RegExp(c).test("0" + e[t - 1])) return e[t] = e[t - 1], e[t - 1] = "0", 
@@ -1166,7 +1170,7 @@
                         postValidation: function(e, t, n, i, a, r, o, l) {
                             var c, u, f = this;
                             if (o) return !0;
-                            if (!1 === i && (((c = j(t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j(t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
+                            if (!1 === i && (((c = j.call(f, t + 1, a, r)).targetMatch && c.targetMatchIndex === t && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]] || (c = j.call(f, t + 2, a, r)).targetMatch && c.targetMatchIndex === t + 1 && c.targetMatch[0].length > 1 && void 0 !== y[c.targetMatch[0]]) && (u = w(c.targetMatch)[0]), 
                             void 0 !== u && (void 0 !== r.validPositions[t + 1] && new RegExp(u).test(n + "0") ? (e[t] = n, 
                             e[t + 1] = "0", i = {
                                 pos: t + 2,
@@ -1174,7 +1178,7 @@
                             }) : new RegExp(u).test("0" + n) && (e[t] = "0", e[t + 1] = n, i = {
                                 pos: t + 2
                             })), !1 === i)) return i;
-                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j(t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
+                            if (i.fuzzy && (e = i.buffer, t = i.pos), (c = j.call(f, t, a, r)).targetMatch && c.targetMatch[0] && void 0 !== y[c.targetMatch[0]]) {
                                 var p = w(c.targetMatch);
                                 u = p[0];
                                 var d = e.slice(c.targetMatchIndex, c.targetMatchIndex + c.targetMatch[0].length);

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


+ 3 - 1
inputmask-pages/src/assets/Changelog.md

@@ -14,7 +14,9 @@
 - Enhance resolving of the ndxInitializer to determine the alternating tests.
 
 ### Fixed
-- d/mm/yyyy is converted to d/m//yyyd #2394 (WIP)
+- ALT codes #2779
+- Pressing the Win button #2780
+- d/mm/yyyy is converted to d/m//yyyd #2394
 - how to get value from input-mask element? #2702
 - Problem with seconds in format 'HH:MM:ss' #2745
 - Remove unused mask - Take2 #2748

+ 21 - 8
lib/extensions/inputmask.date.extensions.js

@@ -38,10 +38,10 @@ class DateObject {
 			let dynMatches = new RegExp("\\d+$").exec(match[0]), fcode = dynMatches ? (match[0][0] + "x") : match[0],
 				value;
 			if (mask !== undefined) {
-				console.log("mask", mask);
+				// console.log("mask", mask);
 				if (dynMatches) {
 					let lastIndex = getTokenizer(opts).lastIndex,
-						tokenMatch = getTokenMatch(match.index, opts, inputmask && inputmask.maskset);
+						tokenMatch = getTokenMatch.call(inputmask, match.index, opts, inputmask && inputmask.maskset);
 					getTokenizer(opts).lastIndex = lastIndex;
 					value = mask.slice(0, mask.indexOf(tokenMatch.nextMatch[0]));
 				} else {
@@ -294,7 +294,7 @@ function isValidDate(dateParts, currentResult, opts) {
 		return currentResult;
 	} else { //take corrective action if possible
 		if (dateParts.day == "29") {
-			var tokenMatch = getTokenMatch(currentResult.pos, opts, inputmask.maskset);
+			var tokenMatch = getTokenMatch.call(inputmask, currentResult.pos, opts, inputmask.maskset);
 			if (tokenMatch.targetMatch && tokenMatch.targetMatch[0] === "yyyy" && currentResult.pos - tokenMatch.targetMatchIndex === 2) {
 				currentResult.remove = currentResult.pos + 1;
 				return currentResult;
@@ -432,12 +432,24 @@ function importDate(dateObj, opts) {
 }
 
 function getTokenMatch(pos, opts, maskset) {
+	var inputmask = this;
 	var masksetHint = (maskset && maskset.tests[pos]) ? maskset.tests[pos][0].match.placeholder : "";
 	var calcPos = 0, targetMatch, match, matchLength = 0;
 	getTokenizer(opts).lastIndex = 0;
 	while ((match = getTokenizer(opts).exec(opts.inputFormat))) {
 		var dynMatches = new RegExp("\\d+$").exec(match[0]);
-		matchLength = dynMatches ? parseInt(dynMatches[0]) : match[0].length;
+		if (dynMatches) {
+			matchLength =  parseInt(dynMatches[0]);
+		} else {
+			let targetSymbol = match[0][0],
+				ndx = calcPos;
+			while (inputmask && getTest.call(inputmask, ndx).match.placeholder === targetSymbol) {
+				ndx++;
+			}
+			matchLength = ndx - calcPos;
+			if(matchLength === 0) matchLength = match[0].length;
+		}
+
 		calcPos += matchLength;
 		if (match[0].indexOf(masksetHint) != -1 || calcPos >= pos + 1) {
 			// console.log("gettokenmatch " + match[0] + " ~ " + (maskset ? maskset.tests[pos][0].match.placeholder : ""));
@@ -478,9 +490,10 @@ Inputmask.extendAliases({
 		max: null, //needs to be in the same format as the inputfornat,
 		skipOptionalPartCharacter: "",
 		preValidation: function (buffer, pos, c, isSelection, opts, maskset, caretPos, strict) {
+			const inputmask = this;
 			if (strict) return true;
 			if (isNaN(c) && buffer[pos] !== c) {
-				var tokenMatch = getTokenMatch(pos, opts);
+				var tokenMatch = getTokenMatch.call(inputmask, pos, opts, maskset);
 				if (tokenMatch.nextMatch && tokenMatch.nextMatch[0] === c && tokenMatch.targetMatch[0].length > 1) {
 					var validator = formatcode(tokenMatch.targetMatch)[0];
 					if (new RegExp(validator).test("0" + buffer[pos - 1])) {
@@ -500,11 +513,11 @@ Inputmask.extendAliases({
 			if (strict) return true;
 			var tokenMatch, validator;
 			if (currentResult === false) { //try some shifting
-				tokenMatch = getTokenMatch(pos + 1, opts, maskset);
+				tokenMatch = getTokenMatch.call(inputmask, pos + 1, opts, maskset);
 				if (tokenMatch.targetMatch && tokenMatch.targetMatchIndex === pos && tokenMatch.targetMatch[0].length > 1 && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
 					validator = formatcode(tokenMatch.targetMatch)[0];
 				} else {
-					tokenMatch = getTokenMatch(pos + 2, opts, maskset);
+					tokenMatch = getTokenMatch.call(inputmask,pos + 2, opts, maskset);
 					if (tokenMatch.targetMatch && tokenMatch.targetMatchIndex === pos + 1 && tokenMatch.targetMatch[0].length > 1 && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
 						validator = formatcode(tokenMatch.targetMatch)[0];
 					}
@@ -537,7 +550,7 @@ Inputmask.extendAliases({
 			}
 
 			//full validate target
-			tokenMatch = getTokenMatch(pos, opts, maskset);
+			tokenMatch = getTokenMatch.call(inputmask, pos, opts, maskset);
 			if (tokenMatch.targetMatch && tokenMatch.targetMatch[0] && formatCode[tokenMatch.targetMatch[0]] !== undefined) {
 				let fcode = formatcode(tokenMatch.targetMatch);
 				validator = fcode[0];

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.52",
+  "version": "5.0.9-beta.53",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "exports": {

+ 24 - 0
qunit/tests_date.js

@@ -1334,6 +1334,18 @@ export default function (qunit, Inputmask) {
 		assert.equal(testmask.value, "29 February 2024", "Result " + testmask.value);
 	});
 
+	qunit.test("mmmm dd yyyy - #2751", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append("<input type=\"text\" id=\"testmask\" />");
+		var testmask = document.getElementById("testmask");
+		Inputmask("datetime", {
+			inputFormat: "mmmm dd yyyy",
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("february292024");
+		assert.equal(testmask.value, "February 29 2024", "Result " + testmask.value);
+	});
+
 	qunit.test("dd mmm yyyy - #2751", function (assert) {
 		var $fixture = $("#qunit-fixture");
 		$fixture.append("<input type=\"text\" id=\"testmask\" />");
@@ -1345,4 +1357,16 @@ export default function (qunit, Inputmask) {
 		$("#testmask").Type("29feb2024");
 		assert.equal(testmask.value, "29 Feb 2024", "Result " + testmask.value);
 	});
+
+	qunit.test("mmm dd yyyy - #2751", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append("<input type=\"text\" id=\"testmask\" />");
+		var testmask = document.getElementById("testmask");
+		Inputmask("datetime", {
+			inputFormat: "mmm dd yyyy",
+		}).mask(testmask);
+		testmask.focus();
+		$("#testmask").Type("feb292024");
+		assert.equal(testmask.value, "Feb 29 2024", "Result " + testmask.value);
+	});
 }

+ 7 - 1
webpack.config.js

@@ -74,6 +74,9 @@ module.exports = function (env, argv) {
 						ascii_only: true,
 						beautify: false,
 						comments: /^!/
+					},
+					compress: {
+						drop_console: env === "production",
 					}
 				},
 				extractComments: false
@@ -85,7 +88,10 @@ module.exports = function (env, argv) {
 						ascii_only: true,
 						beautify: true,
 						comments: /^!/
-					}
+					},
+					compress: {
+						drop_console: env === "production",
+					},
 				},
 				extractComments: false
 			})]