RonaldJerez / vue-input-facade

A lightweight and dependency free input masking library created specific for Vue
https://ronaldjerez.github.io/vue-input-facade/latest/
183 stars 27 forks source link

question: when using multiple masks, what determines the priority? #25

Closed pancake-boy closed 4 years ago

pancake-boy commented 4 years ago

masks = "+### ########", "+## ########"

When i type '12' then '3', i get '+12 3', so it seems to be matching the 2nd mask first. Is there a way to match the 1st one instead?

RonaldJerez commented 4 years ago

Hi, the mask array gets sorted by length internally. This was inherited from vue the mask. After that the priority is which ever mask gives you the most amount of user typed data.

So in your example, the 2nd mask is shorter in length so it gets evaluated first. Which makes sense because otherwise it will never be used since the first mask will always work for whatever numbers the user types in.