src/mask.js
function getMaskComponents() {
                                var maskPlaceholderChars = maskPlaceholder.split(''),
                                        maskPlaceholderCopy, components;

                                //maskCaretMap can have bad values if the input has the ui-mask attribute implemented as an obversable property, e.g. the demo page
                                if (maskCaretMap && !isNaN(maskCaretMap[0])) {
                                    //Instead of trying to manipulate the RegEx based on the placeholder characters
                                    //we can simply replace the placeholder characters based on the already built
                                    //maskCaretMap to underscores and leave the original working RegEx to get the proper
                                    //mask components
                                    angular.forEach(maskCaretMap, function(value) {
                                        maskPlaceholderChars[value] = '_';
                                    });
                                }
                                maskPlaceholderCopy = maskPlaceholderChars.join('');
                                components = maskPlaceholderCopy.replace(/[_]+/g, '_').split('_');
                                components = components.filter(function(s) {
                                    return s !== '';
                                });

                                // need a string search offset in cases where the mask contains multiple identical components
                                // E.g., a mask of 99.99.99-999.99
                                var offset = 0;
                                return components.map(function(c) {
                                    var componentPosition = maskPlaceholderCopy.indexOf(c, offset);
                                    offset = componentPosition + 1;
                                    return {
                                        value: c,
                                        position: componentPosition
                                    };
                                });
                            }
function getMaskComponents() {
                                var maskPlaceholderChars = maskPlaceholder.split(''),
                                        maskPlaceholderCopy, components;

                                //maskCaretMap can have bad values if the input has the ui-mask attribute implemented as an obversable property, e.g. the demo page
                                if (maskCaretMap && !isNaN(maskCaretMap[0])) {
                                    //Instead of trying to manipulate the RegEx based on the placeholder characters
                                    //we can simply replace the placeholder characters based on the already built
                                    //maskCaretMap to underscores and leave the original working RegEx to get the proper
                                    //mask components
                                    angular.forEach(maskCaretMap, function(value) {
                                        maskPlaceholderChars[value] = '_';
                                    });
                                }
                                maskPlaceholderCopy = maskPlaceholderChars.join('');
                                components = maskPlaceholderCopy.replace(/[_]+/g, '_').split('_');
                                components = components.filter(function(s) {
                                    return s !== '';
                                });

                                // need a string search offset in cases where the mask contains multiple identical components
                                // E.g., a mask of 99.99.99-999.99
                                var offset = 0;
                                return components.map(function(c) {
                                    var componentPosition = maskPlaceholderCopy.indexOf(c, offset);
                                    offset = componentPosition + 1;
                                    return {
                                        value: c,
                                        position: componentPosition
                                    };
                                });
                            }
function getMaskComponents ( ) { var maskPlaceholderChars = maskPlaceholder . split ( '' ) , maskPlaceholderCopy , components ; //maskCaretMap can have bad values if the input has the ui-mask attribute implemented as an obversable property, e.g. the demo page if ( maskCaretMap && ! isNaN ( maskCaretMap [ 0 ] ) ) { //Instead of trying to manipulate the RegEx based on the placeholder characters //we can simply replace the placeholder characters based on the already built //maskCaretMap to underscores and leave the original working RegEx to get the proper //mask components angular . forEach ( maskCaretMap , function ( value ) { maskPlaceholderChars [ value ] = '_' ; } ) ; } maskPlaceholderCopy = maskPlaceholderChars . join ( '' ) ; components = maskPlaceholderCopy . replace ( / [_]+ / g , '_' ) . split ( '_' ) ; components = components . filter ( function ( s ) { return s !== '' ; } ) ; // need a string search offset in cases where the mask contains multiple identical components // E.g., a mask of 99.99.99-999.99 var offset = 0 ; return components . map ( function ( c ) { var componentPosition = maskPlaceholderCopy . indexOf ( c , offset ) ; offset = componentPosition + 1 ; return { value : c , position : componentPosition } ; } ) ; }
Generate array of mask components that will be stripped from a masked value before processing to prevent mask components from being added to the unmasked value. E.g., a mask pattern of '+7 9999' won't have the 7 bleed into the unmasked value.
Generate array of mask components that will be stripped from a masked value before processing to prevent mask components from being added to the unmasked value . E . g . a mask pattern of + 7 9999 won t have the 7 bleed into the unmasked value .