lib/validation.js
//fill in best positions according the current input
fill in best positions according the current input
fill in best positions according the current input
function trackbackPositions(originalPos, newPos, fillOnly) {
	const inputmask = this,
		maskset = this.maskset,
		$ = this.dependencyLib;
	if (originalPos === undefined) {
		for (originalPos = newPos - 1; originalPos > 0; originalPos--) {
			if (maskset.validPositions[originalPos]) break;
		}
	}
	for (var ps = originalPos; ps < newPos; ps++) {
		if (maskset.validPositions[ps] === undefined && !isMask.call(inputmask, ps, false)) {
			var vp = ps == 0 ? getTest.call(inputmask, ps) : maskset.validPositions[ps - 1];
			if (vp) {
				var tests = getTests.call(inputmask, ps).slice();
				if (tests[tests.length - 1].match.def === "") tests.pop();
				var bestMatch = determineTestTemplate.call(inputmask, ps, tests), np;
				if (bestMatch && (bestMatch.match.jit !== true || (bestMatch.match.newBlockMarker === "master" && (np = maskset.validPositions[ps + 1]) && np.match.optionalQuantifier === true))) {
					bestMatch = $.extend({}, bestMatch, {
						"input": getPlaceholder.call(inputmask, ps, bestMatch.match, true) || bestMatch.match.def
					});
					bestMatch.generatedInput = true;
					revalidateMask.call(inputmask, ps, bestMatch, true);
					if (fillOnly !== true) {
						var cvpInput = maskset.validPositions[newPos].input;
						maskset.validPositions[newPos] = undefined;
						return isValid.call(inputmask, newPos, cvpInput, true, true);
					}
				}
			}
		}
	}
}
function trackbackPositions ( originalPos , newPos , fillOnly ) { const inputmask = this , maskset = this . maskset , $ = this . dependencyLib ; if ( originalPos === undefined ) { for ( originalPos = newPos - 1 ; originalPos > 0 ; originalPos -- ) { if ( maskset . validPositions [ originalPos ] ) break ; } } for ( var ps = originalPos ; ps < newPos ; ps ++ ) { if ( maskset . validPositions [ ps ] === undefined && ! isMask . call ( inputmask , ps , false ) ) { var vp = ps == 0 ? getTest . call ( inputmask , ps ) : maskset . validPositions [ ps - 1 ] ; if ( vp ) { var tests = getTests . call ( inputmask , ps ) . slice ( ) ; if ( tests [ tests . length - 1 ] . match . def === "" ) tests . pop ( ) ; var bestMatch = determineTestTemplate . call ( inputmask , ps , tests ) , np ; if ( bestMatch && ( bestMatch . match . jit !== true || ( bestMatch . match . newBlockMarker === "master" && ( np = maskset . validPositions [ ps + 1 ] ) && np . match . optionalQuantifier === true ) ) ) { bestMatch = $ . extend ( { } , bestMatch , { "input" : getPlaceholder . call ( inputmask , ps , bestMatch . match , true ) || bestMatch . match . def } ) ; bestMatch . generatedInput = true ; revalidateMask . call ( inputmask , ps , bestMatch , true ) ; if ( fillOnly !== true ) { var cvpInput = maskset . validPositions [ newPos ] . input ; maskset . validPositions [ newPos ] = undefined ; return isValid . call ( inputmask , newPos , cvpInput , true , true ) ; } } } } } }
fill in best positions according the current input
fill in best positions according the current input
// console.log("trackbackPositions " + originalPos + " " + newPos); //find previous valid //revalidate the new position to update the locator value