(mtoken, element, position)
| 274 | }; |
| 275 | } |
| 276 | function insertTestDefinition(mtoken, element, position) { |
| 277 | position = position !== undefined ? position : mtoken.matches.length; |
| 278 | var prevMatch = mtoken.matches[position - 1]; |
| 279 | if (regexMask) { |
| 280 | if (element.indexOf("[") === 0 || escaped && /\\d|\\s|\\w]/i.test(element) || element === ".") { |
| 281 | mtoken.matches.splice(position++, 0, { |
| 282 | fn: new RegExp(element, opts.casing ? "i" : ""), |
| 283 | optionality: false, |
| 284 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== element, |
| 285 | casing: null, |
| 286 | def: element, |
| 287 | placeholder: undefined, |
| 288 | nativeDef: element |
| 289 | }); |
| 290 | } else { |
| 291 | if (escaped) element = element[element.length - 1]; |
| 292 | $.each(element.split(""), function(ndx, lmnt) { |
| 293 | prevMatch = mtoken.matches[position - 1]; |
| 294 | mtoken.matches.splice(position++, 0, { |
| 295 | fn: null, |
| 296 | optionality: false, |
| 297 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== lmnt && prevMatch.fn !== null, |
| 298 | casing: null, |
| 299 | def: opts.staticDefinitionSymbol || lmnt, |
| 300 | placeholder: opts.staticDefinitionSymbol !== undefined ? lmnt : undefined, |
| 301 | nativeDef: (escaped ? "'" : "") + lmnt |
| 302 | }); |
| 303 | }); |
| 304 | } |
| 305 | escaped = false; |
| 306 | } else { |
| 307 | var maskdef = (opts.definitions ? opts.definitions[element] : undefined) || Inputmask.prototype.definitions[element]; |
| 308 | if (maskdef && !escaped) { |
| 309 | // This for-loop implements "cardinality" |
| 310 | // Removed in 4.x for unknown reasons. |
| 311 | // Backported from https://github.com/RobinHerbots/Inputmask/blob/8d0c60f8/js/inputmask.js#L371 |
| 312 | for (var prevalidators = maskdef.prevalidator, prevalidatorsL = prevalidators ? prevalidators.length : 0, i = 1; i < maskdef.cardinality; i++) { |
| 313 | var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator.validator, cardinality = prevalidator.cardinality; |
| 314 | mtoken.matches.splice(position++, 0, { |
| 315 | fn: validator ? "string" == typeof validator ? new RegExp(validator, opts.casing ? "i" : "") : new function() { |
| 316 | this.test = validator; |
| 317 | }() : new RegExp("."), |
| 318 | cardinality: cardinality || 1, |
| 319 | optionality: mtoken.isOptional, |
| 320 | newBlockMarker: prevMatch === undefined || prevMatch.def !== (maskdef.definitionSymbol || element), |
| 321 | casing: maskdef.casing, |
| 322 | def: maskdef.definitionSymbol || element, |
| 323 | placeholder: maskdef.placeholder, |
| 324 | nativeDef: element |
| 325 | }), prevMatch = mtoken.matches[position - 1]; |
| 326 | } |
| 327 | mtoken.matches.splice(position++, 0, { |
| 328 | fn: maskdef.validator ? typeof maskdef.validator == "string" ? new RegExp(maskdef.validator, opts.casing ? "i" : "") : new function() { |
| 329 | this.test = maskdef.validator; |
| 330 | }() : new RegExp("."), |
| 331 | optionality: false, |
| 332 | newBlockMarker: prevMatch === undefined ? "master" : prevMatch.def !== (maskdef.definitionSymbol || element), |
| 333 | casing: maskdef.casing, |
no test coverage detected