use-mask-input 1.0.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/example/App.example.d.ts +3 -0
  2. package/dist/{useMaskInput.test.d.ts → example/index.d.ts} +0 -0
  3. package/dist/index.js +1 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +1 -2
  6. package/dist/index.modern.js.map +1 -1
  7. package/dist/useMaskInput.d.ts +3 -3
  8. package/node_modules/inputmask/README.md +94 -61
  9. package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
  10. package/node_modules/inputmask/dist/inputmask.js +2900 -2868
  11. package/node_modules/inputmask/dist/inputmask.min.js +3 -3
  12. package/node_modules/inputmask/dist/jquery.inputmask.js +2840 -2807
  13. package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
  14. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
  15. package/node_modules/inputmask/lib/canUseDOM.js +7 -0
  16. package/node_modules/inputmask/lib/defaults.js +36 -2
  17. package/node_modules/inputmask/lib/definitions.js +1 -1
  18. package/node_modules/inputmask/lib/dependencyLibs/events.js +19 -9
  19. package/node_modules/inputmask/lib/environment.js +2 -0
  20. package/node_modules/inputmask/lib/eventhandlers.js +55 -44
  21. package/node_modules/inputmask/lib/eventruler.js +10 -9
  22. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +543 -430
  23. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +117 -99
  24. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +590 -574
  25. package/node_modules/inputmask/lib/global/window.js +2 -1
  26. package/node_modules/inputmask/lib/inputHandling.js +30 -18
  27. package/node_modules/inputmask/lib/inputmask.js +9 -2
  28. package/node_modules/inputmask/lib/inputmaskElement.js +2 -1
  29. package/node_modules/inputmask/lib/keycode.json +4 -0
  30. package/node_modules/inputmask/lib/mask-lexer.js +434 -436
  31. package/node_modules/inputmask/lib/mask.js +4 -4
  32. package/node_modules/inputmask/lib/masktoken.js +13 -0
  33. package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
  34. package/node_modules/inputmask/lib/{getPrototypeOf.js → polyfills/Object.getPrototypeOf.js} +0 -0
  35. package/node_modules/inputmask/lib/positioning.js +5 -5
  36. package/node_modules/inputmask/lib/validation-tests.js +108 -46
  37. package/node_modules/inputmask/lib/validation.js +82 -73
  38. package/node_modules/inputmask/package.json +41 -69
  39. package/package.json +40 -38
  40. package/node_modules/inputmask/CHANGELOG.md +0 -744
  41. package/node_modules/inputmask/index.js +0 -1
  42. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -20
@@ -1,4 +1,3 @@
1
- import "./getPrototypeOf";
2
1
  import keyCode from "./keycode.json";
3
2
  import {caret, getBuffer, getBufferTemplate, getLastValidPosition, resetMaskSet, seekNext} from "./positioning";
4
3
  import {applyInputValue, clearOptionalTail, writeBuffer} from "./inputHandling";
@@ -61,7 +60,7 @@ function mask() {
61
60
  return this.inputmask.opts.autoUnmask ?
62
61
  this.inputmask.unmaskedvalue() :
63
62
  (getLastValidPosition.call(inputmask) !== -1 || opts.nullable !== true ?
64
- ((this.inputmask.shadowRoot || document.activeElement) === this && opts.clearMaskOnLostFocus ?
63
+ (((this.inputmask.shadowRoot || this.ownerDocument).activeElement) === this && opts.clearMaskOnLostFocus ?
65
64
  (inputmask.isRTL ? clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice()).reverse() : clearOptionalTail.call(inputmask,getBuffer.call(inputmask).slice())).join("") :
66
65
  valueGet.call(this)) :
67
66
  "");
@@ -216,8 +215,9 @@ function mask() {
216
215
  EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
217
216
 
218
217
  //apply mask
219
- inputmask.undoValue = getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
220
- var activeElement = (el.inputmask.shadowRoot || document).activeElement;
218
+ getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
219
+ inputmask.undoValue = inputmask._valueGet(true);
220
+ var activeElement = (el.inputmask.shadowRoot || el.ownerDocument).activeElement;
221
221
  if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || activeElement === el) {
222
222
  applyInputValue(el, el.inputmask._valueGet(true), opts);
223
223
  var buffer = getBuffer.call(inputmask).slice();
@@ -0,0 +1,13 @@
1
+ export default function (isGroup, isOptional, isQuantifier, isAlternator) {
2
+ this.matches = [];
3
+ this.openGroup = isGroup || false;
4
+ this.alternatorGroup = false;
5
+ this.isGroup = isGroup || false;
6
+ this.isOptional = isOptional || false;
7
+ this.isQuantifier = isQuantifier || false;
8
+ this.isAlternator = isAlternator || false;
9
+ this.quantifier = {
10
+ min: 1,
11
+ max: 1
12
+ };
13
+ }
@@ -0,0 +1,48 @@
1
+ // https://tc39.github.io/ecma262/#sec-array.prototype.includes
2
+ if (!Array.prototype.includes) {
3
+ Object.defineProperty(Array.prototype, "includes", {
4
+ value: function(searchElement, fromIndex) {
5
+
6
+ // 1. Let O be ? ToObject(this value).
7
+ if (this == null) {
8
+ throw new TypeError("\"this\" is null or not defined");
9
+ }
10
+
11
+ var o = Object(this);
12
+
13
+ // 2. Let len be ? ToLength(? Get(O, "length")).
14
+ var len = o.length >>> 0;
15
+
16
+ // 3. If len is 0, return false.
17
+ if (len === 0) {
18
+ return false;
19
+ }
20
+
21
+ // 4. Let n be ? ToInteger(fromIndex).
22
+ // (If fromIndex is undefined, this step produces the value 0.)
23
+ var n = fromIndex | 0;
24
+
25
+ // 5. If n ≥ 0, then
26
+ // a. Let k be n.
27
+ // 6. Else n < 0,
28
+ // a. Let k be len + n.
29
+ // b. If k < 0, let k be 0.
30
+ var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
31
+
32
+ // 7. Repeat, while k < len
33
+ while (k < len) {
34
+ // a. Let elementK be the result of ? Get(O, ! ToString(k)).
35
+ // b. If SameValueZero(searchElement, elementK) is true, return true.
36
+ // c. Increase k by 1.
37
+ // NOTE: === provides the correct "SameValueZero" comparison needed here.
38
+ if (o[k] === searchElement) {
39
+ return true;
40
+ }
41
+ k++;
42
+ }
43
+
44
+ // 8. Return false
45
+ return false;
46
+ }
47
+ });
48
+ }
@@ -7,7 +7,6 @@ import {
7
7
  getTestTemplate
8
8
  } from "./validation-tests";
9
9
  import {checkAlternationMatch} from "./validation";
10
- import {mask} from "./mask";
11
10
 
12
11
  export {
13
12
  caret,
@@ -54,7 +53,7 @@ function caret(input, begin, end, notranslate, isDelete) {
54
53
  end++; //set visualization for insert/overwrite mode
55
54
  }
56
55
  }
57
- if (input === (input.inputmask.shadowRoot || document).activeElement) {
56
+ if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
58
57
  if ("setSelectionRange" in input) {
59
58
  input.setSelectionRange(begin, end);
60
59
  } else if (window.getSelection) {
@@ -152,7 +151,7 @@ function determineLastRequiredPosition(returnDefinition) {
152
151
  }
153
152
 
154
153
  //tobe put on prototype?
155
- function determineNewCaretPosition(selectedCaret, tabbed) {
154
+ function determineNewCaretPosition(selectedCaret, tabbed, positionCaretOnClick) {
156
155
  const inputmask = this,
157
156
  maskset = this.maskset,
158
157
  opts = this.opts;
@@ -184,7 +183,8 @@ function determineNewCaretPosition(selectedCaret, tabbed) {
184
183
  }
185
184
  }
186
185
  if (selectedCaret.begin === selectedCaret.end) {
187
- switch (opts.positionCaretOnClick) {
186
+ positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
187
+ switch (positionCaretOnClick) {
188
188
  case "none":
189
189
  break;
190
190
  case "select":
@@ -342,7 +342,7 @@ function translatePosition(pos) {
342
342
  el = this.el;
343
343
 
344
344
  if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
345
- pos = inputmask._valueGet().length - pos;
345
+ pos = Math.abs(inputmask._valueGet().length - pos);
346
346
  }
347
347
  return pos;
348
348
  }
@@ -1,4 +1,14 @@
1
- export {determineTestTemplate, getDecisionTaker, getMaskTemplate, getPlaceholder, getTest, getTests, getTestTemplate};
1
+ export {
2
+ determineTestTemplate,
3
+ getDecisionTaker,
4
+ getMaskTemplate,
5
+ getPlaceholder,
6
+ getTest,
7
+ getTests,
8
+ getTestTemplate,
9
+ isSubsetOf
10
+ };
11
+ import Inputmask from "./inputmask";
2
12
 
3
13
  function getLocator(tst, align) { //need to align the locators to be correct
4
14
  var locator = (tst.alternation != undefined ? tst.mloc[getDecisionTaker(tst)] : tst.locator).join("");
@@ -59,14 +69,17 @@ function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptio
59
69
 
60
70
 
61
71
  var greedy = opts.greedy;
62
- if (clearOptionalTail) opts.greedy = false;
72
+ if (clearOptionalTail && opts.greedy) {
73
+ opts.greedy = false;
74
+ inputmask.maskset.tests = {};
75
+ }
63
76
  minimalPos = minimalPos || 0;
64
77
  var maskTemplate = [],
65
78
  ndxIntlzr, pos = 0,
66
79
  test, testPos, jitRenderStatic;
67
80
  do {
68
81
  if (baseOnInput === true && maskset.validPositions[pos]) {
69
- testPos = (clearOptionalTail && maskset.validPositions[pos].match.optionality === true
82
+ testPos = (clearOptionalTail && maskset.validPositions[pos].match.optionality
70
83
  && maskset.validPositions[pos + 1] === undefined
71
84
  && (maskset.validPositions[pos].generatedInput === true || (maskset.validPositions[pos].input == opts.skipOptionalPartCharacter && pos > 0)))
72
85
  ? determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos, ndxIntlzr, pos - 1))
@@ -80,7 +93,7 @@ function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptio
80
93
  ndxIntlzr = testPos.locator.slice();
81
94
  var jitMasking = noJit === true ? false : (opts.jitMasking !== false ? opts.jitMasking : test.jit);
82
95
  //check for groupSeparator is a hack for the numerics as we don't want the render of the groupSeparator beforehand
83
- jitRenderStatic = (jitRenderStatic && test.static && test.def !== opts.groupSeparator && test.fn === null) || (maskset.validPositions[pos - 1] && test.static && test.def !== opts.groupSeparator && test.fn === null);
96
+ jitRenderStatic = ((jitRenderStatic && test.static && test.def !== opts.groupSeparator && test.fn === null) || (maskset.validPositions[pos - 1] && test.static && test.def !== opts.groupSeparator && test.fn === null)) && maskset.tests[pos] && maskset.tests[pos].length === 1;
84
97
  if (jitRenderStatic || jitMasking === false || jitMasking === undefined /*|| pos < lvp*/ || (typeof jitMasking === "number" && isFinite(jitMasking) && jitMasking > pos)) {
85
98
  maskTemplate.push(includeMode === false ? test.nativeDef : getPlaceholder.call(inputmask, pos, test));
86
99
  } else {
@@ -89,7 +102,7 @@ function getMaskTemplate(baseOnInput, minimalPos, includeMode, noJit, clearOptio
89
102
  }
90
103
 
91
104
  pos++;
92
- } while ((inputmask.maxLength === undefined || pos < inputmask.maxLength) && (test.static !== true || test.def !== "") || minimalPos > pos);
105
+ } while ((test.static !== true || test.def !== "") || minimalPos > pos);
93
106
  if (maskTemplate[maskTemplate.length - 1] === "") {
94
107
  maskTemplate.pop(); //drop the last one which is empty
95
108
  }
@@ -115,25 +128,51 @@ function getTestTemplate(pos, ndxIntlzr, tstPs) {
115
128
  function determineTestTemplate(pos, tests) {
116
129
  var inputmask = this,
117
130
  opts = this.opts;
118
-
131
+ var optionalityLevel = determineOptionalityLevel(pos, tests);
119
132
  pos = pos > 0 ? pos - 1 : 0;
120
133
  var altTest = getTest.call(inputmask, pos), targetLocator = getLocator(altTest), tstLocator, closest, bestMatch;
134
+ if (opts.greedy && tests.length > 1 && tests[tests.length - 1].match.def === "")
135
+ tests.pop();
136
+ // console.log(" optionality = " + optionalityLevel);
137
+ // console.log(" - " + JSON.stringify(tests));
121
138
  for (var ndx = 0; ndx < tests.length; ndx++) { //find best matching
122
139
  var tst = tests[ndx];
123
140
  tstLocator = getLocator(tst, targetLocator.length);
124
141
  var distance = Math.abs(tstLocator - targetLocator);
142
+
125
143
  if (closest === undefined
126
144
  || (tstLocator !== "" && distance < closest)
127
- || (bestMatch && !opts.greedy && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker))
128
- || (bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier)) {
145
+ || (bestMatch && !opts.greedy &&
146
+ (bestMatch.match.optionality && bestMatch.match.optionality - optionalityLevel > 0) &&
147
+ bestMatch.match.newBlockMarker === "master" &&
148
+ ((!tst.match.optionality || tst.match.optionality - optionalityLevel < 1) || !tst.match.newBlockMarker))
149
+ || (bestMatch && !opts.greedy && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier)) {
129
150
  closest = distance;
130
151
  bestMatch = tst;
131
152
  }
132
153
  }
133
-
134
154
  return bestMatch;
135
155
  }
136
156
 
157
+ function determineOptionalityLevel(pos, tests) {
158
+ let optionalityLevel = 0, differentOptionalLevels = false;
159
+ tests.forEach(test => {
160
+ if (test.match.optionality) {
161
+ if (optionalityLevel !== 0 && optionalityLevel !== test.match.optionality)
162
+ differentOptionalLevels = true;
163
+ if (optionalityLevel === 0 || optionalityLevel > test.match.optionality) {
164
+ optionalityLevel = test.match.optionality;
165
+ }
166
+ }
167
+ });
168
+ if (optionalityLevel) {
169
+ if (pos == 0) optionalityLevel = 0;
170
+ else if (tests.length == 1) optionalityLevel = 0;
171
+ else if (!differentOptionalLevels) optionalityLevel = 0;
172
+ }
173
+ return optionalityLevel;
174
+ }
175
+
137
176
  //tobe put on prototype?
138
177
  function getTest(pos, tests) {
139
178
  var inputmask = this,
@@ -145,6 +184,28 @@ function getTest(pos, tests) {
145
184
  return (tests || getTests.call(inputmask, pos))[0];
146
185
  }
147
186
 
187
+ function isSubsetOf(source, target, opts) {
188
+ function expand(pattern) {
189
+ var expanded = [], start = -1, end;
190
+ for (var i = 0, l = pattern.length; i < l; i++) {
191
+ if (pattern.charAt(i) === "-") {
192
+ end = pattern.charCodeAt(i + 1);
193
+ while (++start < end) expanded.push(String.fromCharCode(start));
194
+ } else {
195
+ start = pattern.charCodeAt(i);
196
+ expanded.push(pattern.charAt(i));
197
+ }
198
+ }
199
+ return expanded.join("");
200
+ }
201
+
202
+ if (source.match.def === target.match.nativeDef) return true;
203
+ if ((opts.regex || (source.match.fn instanceof RegExp && target.match.fn instanceof RegExp)) && source.match.static !== true && target.match.static !== true) { //is regex a subset
204
+ return expand(target.match.fn.toString().replace(/[[\]/]/g, "")).indexOf(expand(source.match.fn.toString().replace(/[[\]/]/g, ""))) !== -1;
205
+ }
206
+ return false;
207
+ }
208
+
148
209
  //tobe put on prototype?
149
210
  function getTests(pos, ndxIntlzr, tstPs) {
150
211
  var inputmask = this,
@@ -205,28 +266,6 @@ function getTests(pos, ndxIntlzr, tstPs) {
205
266
  }
206
267
  }
207
268
 
208
- function isSubsetOf(source, target) {
209
- function expand(pattern) {
210
- var expanded = [], start = -1, end;
211
- for (var i = 0, l = pattern.length; i < l; i++) {
212
- if (pattern.charAt(i) === "-") {
213
- end = pattern.charCodeAt(i + 1);
214
- while (++start < end) expanded.push(String.fromCharCode(start));
215
- } else {
216
- start = pattern.charCodeAt(i);
217
- expanded.push(pattern.charAt(i));
218
- }
219
- }
220
- return expanded.join("");
221
- }
222
-
223
- if (source.match.def === target.match.nativeDef) return true;
224
- if ((opts.regex || (source.match.fn instanceof RegExp && target.match.fn instanceof RegExp)) && source.match.static !== true && target.match.static !== true) { //is regex a subset
225
- return expand(target.match.fn.toString().replace(/[[\]/]/g, "")).indexOf(expand(source.match.fn.toString().replace(/[[\]/]/g, ""))) !== -1;
226
- }
227
- return false;
228
- }
229
-
230
269
  function staticCanMatchDefinition(source, target) {
231
270
  return source.match.static === true && target.match.static !== true ? target.match.fn.test(source.match.def, maskset, pos, false, opts, false) : false;
232
271
  }
@@ -289,7 +328,14 @@ function getTests(pos, ndxIntlzr, tstPs) {
289
328
  "cd": cacheDependency,
290
329
  "mloc": {}
291
330
  });
292
- return true;
331
+ if (match.optionality && quantifierRecurse === undefined &&
332
+ ((opts.definitions && opts.definitions[match.nativeDef] && opts.definitions[match.nativeDef].optional) ||
333
+ (Inputmask.prototype.definitions[match.nativeDef] && Inputmask.prototype.definitions[match.nativeDef].optional))) { //prevent loop see #698
334
+ insertStop = true; //insert a stop
335
+ testPos = pos; //match the position after the group
336
+ } else {
337
+ return true;
338
+ }
293
339
  } else if (match.matches !== undefined) {
294
340
  if (match.isGroup && quantifierRecurse !== match) { //when a group pass along to the quantifier
295
341
  match = handleMatch(maskToken.matches[maskToken.matches.indexOf(match) + 1], loopNdx, quantifierRecurse);
@@ -301,10 +347,11 @@ function getTests(pos, ndxIntlzr, tstPs) {
301
347
  //mark optionality in matches
302
348
  matches.forEach(function (mtch, ndx) {
303
349
  if (ndx >= mtchsNdx) {
304
- mtch.match.optionality = true;
350
+ mtch.match.optionality = mtch.match.optionality ? mtch.match.optionality + 1 : 1;
305
351
  }
306
352
  });
307
353
  latestMatch = matches[matches.length - 1].match;
354
+
308
355
  if (quantifierRecurse === undefined && isFirstMatch(latestMatch, optionalToken)) { //prevent loop see #698
309
356
  insertStop = true; //insert a stop
310
357
  testPos = pos; //match the position after the group
@@ -317,7 +364,8 @@ function getTests(pos, ndxIntlzr, tstPs) {
317
364
  malternateMatches = [],
318
365
  maltMatches,
319
366
  currentMatches = matches.slice(),
320
- loopNdxCnt = loopNdx.length;
367
+ loopNdxCnt = loopNdx.length,
368
+ unMatchedAlternation = false;
321
369
  var altIndex = ndxInitializer.length > 0 ? ndxInitializer.shift() : -1;
322
370
  if (altIndex === -1 || typeof altIndex === "string") {
323
371
  var currentPos = testPos,
@@ -346,16 +394,21 @@ function getTests(pos, ndxIntlzr, tstPs) {
346
394
  }
347
395
  }
348
396
  if (opts.keepStatic === true || (isFinite(parseInt(opts.keepStatic)) && currentPos >= opts.keepStatic)) altIndexArr = altIndexArr.slice(0, 1);
349
- var unMatchedAlternation = false;
350
397
  for (var ndx = 0; ndx < altIndexArr.length; ndx++) {
351
398
  amndx = parseInt(altIndexArr[ndx]);
352
399
  matches = [];
353
400
  //set the correct ndxInitializer
354
401
  ndxInitializer = typeof altIndex === "string" ? resolveNdxInitializer(testPos, amndx, loopNdxCnt) || ndxInitializerClone.slice() : ndxInitializerClone.slice();
355
- if (alternateToken.matches[amndx] && handleMatch(alternateToken.matches[amndx], [amndx].concat(loopNdx), quantifierRecurse)) {
402
+ var tokenMatch = alternateToken.matches[amndx];
403
+ if (tokenMatch && handleMatch(tokenMatch, [amndx].concat(loopNdx), quantifierRecurse)) {
356
404
  match = true;
357
- } else if (ndx === 0) {
358
- unMatchedAlternation = true;
405
+ } else {
406
+ if (ndx === 0) {
407
+ unMatchedAlternation = true;
408
+ }
409
+ if (tokenMatch && tokenMatch.matches && tokenMatch.matches.length > alternateToken.matches[0].matches.length) {
410
+ break;
411
+ }
359
412
  }
360
413
 
361
414
  maltMatches = matches.slice();
@@ -376,13 +429,13 @@ function getTests(pos, ndxIntlzr, tstPs) {
376
429
  dropMatch = true;
377
430
  setMergeLocators(altMatch2, altMatch);
378
431
  break;
379
- } else if (isSubsetOf(altMatch, altMatch2)) {
432
+ } else if (isSubsetOf(altMatch, altMatch2, opts)) {
380
433
  if (setMergeLocators(altMatch, altMatch2)) {
381
434
  dropMatch = true;
382
435
  malternateMatches.splice(malternateMatches.indexOf(altMatch2), 0, altMatch);
383
436
  }
384
437
  break;
385
- } else if (isSubsetOf(altMatch2, altMatch)) {
438
+ } else if (isSubsetOf(altMatch2, altMatch, opts)) {
386
439
  setMergeLocators(altMatch2, altMatch);
387
440
  break;
388
441
  } else if (staticCanMatchDefinition(altMatch, altMatch2)) {
@@ -426,7 +479,8 @@ function getTests(pos, ndxIntlzr, tstPs) {
426
479
  //TODO FIX RECURSIVE QUANTIFIERS
427
480
  latestMatch.optionalQuantifier = qndx >= qt.quantifier.min;
428
481
  // console.log(pos + " " + qt.quantifier.min + " " + latestMatch.optionalQuantifier);
429
- latestMatch.jit = (qndx || 1) * tokenGroup.matches.indexOf(latestMatch) >= qt.quantifier.jit;
482
+ //qndx + 1 as the index starts from 0
483
+ latestMatch.jit = (qndx + 1) * (tokenGroup.matches.indexOf(latestMatch) + 1) > qt.quantifier.jit;
430
484
  if (latestMatch.optionalQuantifier && isFirstMatch(latestMatch, tokenGroup)) {
431
485
  insertStop = true;
432
486
  testPos = pos; //match the position after the group
@@ -487,7 +541,7 @@ function getTests(pos, ndxIntlzr, tstPs) {
487
541
  return locator;
488
542
  }
489
543
 
490
- if (pos > -1 && (inputmask.maxLength === undefined || pos < inputmask.maxLength)) {
544
+ if (pos > -1) {
491
545
  if (ndxIntlzr === undefined) { //determine index initializer
492
546
  var previousPos = pos - 1,
493
547
  test;
@@ -525,11 +579,19 @@ function getTests(pos, ndxIntlzr, tstPs) {
525
579
  cd: cacheDependency
526
580
  });
527
581
  }
528
-
582
+ var result;
529
583
  if (ndxIntlzr !== undefined && maskset.tests[pos]) { //prioritize full tests for caching
530
- return $.extend(true, [], matches);
584
+ result = $.extend(true, [], matches);
585
+ } else {
586
+ maskset.tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
587
+ result = maskset.tests[pos];
531
588
  }
532
- maskset.tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
589
+
533
590
  // console.log(pos + " - " + JSON.stringify(matches));
534
- return maskset.tests[pos];
591
+ //cleanup optionality marking
592
+ matches.forEach(t => {
593
+ t.match.optionality = false;
594
+ });
595
+
596
+ return result;
535
597
  }