ngx-mask
ngx-mask copied to clipboard
When precision is not specified on "separator" mask error "toFixed() digits argument must be between 0 and 100"
π bug report
Is this a regression?
Yes, this was previously no issue with 17.1.8
Description
Due to the change in _checkPrecision method now using
const separatorPrecision = this.getPrecision(separatorExpression);
instead of previously
const separatorPrecision = separatorExpression.slice(10, 11);
The main problem is with getting separatorPrecision:
-
Old behavior:
separatorPrecision = ""(empty string) -
New behavior:
separatorPrecision = Infinity
This impacts the logic check:
| Check | Result |
|---|---|
Number("") > 0 |
false |
Number(Infinity) > 0 |
true |
Thus, older setups would skip precision logic, but now they always trigger .toFixed(Infinity), causing a RangeError.
π¬ Minimal Reproduction
https://stackblitz.com/edit/stackblitz-starters-grz5cbm8
π₯ Exception or Error
RangeError: toFixed() digits argument must be between 0 and 100
at Number.toFixed ()
at _NgxMaskService._checkPrecision (ngx-mask.mjs:1098:44)
at _NgxMaskDirective. (ngx-mask.mjs:1723:42)
at Generator.next ()
at main.js:49:61
at new ZoneAwarePromise (zone.js:2702:25)
at __async (main.js:33:10)
In the stackblitz example it doesn't stop the control from working, it does in our app though
π Your Environment
Angular Version:
19
Anything else relevant?