Need to display zero fractional digits for currency, but fails on Safari / polyfill/Intl.complete.js
See original GitHub issueOur application requires that we don’t display the fractional portion of currency. The default works fine when not using the polyfill. The polyfill displays the fractional portion by default. When I try to set maximumFractionDigits to zero, the polyfill produces the output below. Is there a different way I should be specifying zero decimal currency values?
Error
column: 84
line: 1083
message: "Value is not a number or outside accepted range"
sourceURL: "http://localhost:4200/assets/intl/polyfill/Intl.complete.js"
stack: "GetNumberOption@http://localhost:4200/assets/intl/polyfill/Intl.complete.js:1083:33
InitializeNumberFormat@http://localhost:4200/assets/intl/polyfill/Intl.complete.js:1287:31
NumberFormatConstructor@http://localhost:4200/assets/intl/polyfill/Intl.complete.js:1104:34
http://localhost:4200/assets/vendor.js:85911:40
_format@http://localhost:4200/assets/my.js:7547:48
formatNumber@http://localhost:4200/assets/my.js:7516:32
http://localhost:4200/assets/my.js:5233:75
get@http://localhost:4200/assets/vendor.js:20958:30
get@http://localhost:4200/assets/vendor.js:26218:22
valueFn@http://localhost:4200/assets/vendor.js:48344:32
value@http://localhost:4200/assets/vendor.js:27297:41
read@http://localhost:4200/assets/vendor.js:27537:26
valueFn@http://localhost:4200/assets/vendor.js:27203:24
value@http://localhost:4200/assets/vendor.js:27297:41
read@http://localhost:4200/assets/vendor.js:27537:26
valueFn@http://localhost:4200/assets/vendor.js:48440:34
value@http://localhost:4200/assets/vendor.js:27297:41
read@http://localhost:4200/assets/vendor.js:27537:26
valueFn@http://localhost:4200/assets/vendor.js:27165:37
value@http://localhost:4200/assets/vendor.js:27297:41
read@http://localhost:4200/assets/vendor.js:27537:26
readArray@http://localhost:4200/assets/vendor.js:27559:20
http://localhost:4200/assets/vendor.js:27652:25
value@http://localhost:4200/assets/vendor.js:27297:41
read@http://localhost:4200/assets/vendor.js:27537:26
render@http://localhost:4200/assets/vendor.js:46729:27
EmberRenderer_createElement@http://localhost:4200/assets/vendor.js:49511:20
Renderer_renderTree@http://localhost:4200/assets/vendor.js:19036:35
ensureChildrenAreInDOM@http://localhost:4200/assets/vendor.js:50813:30
_ensureChildrenAreInDOM@http://localhost:4200/assets/vendor.js:50776:47
invokeWithOnError@http://localhost:4200/assets/vendor.js:11434:24
flush@http://localhost:4200/assets/vendor.js:11490:19
flush@http://localhost:4200/assets/vendor.js:11295:24
end@http://localhost:4200/assets/vendor.js:10720:32
http://localhost:4200/assets/vendor.js:11123:23"
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Intl.NumberFormat either 0 or two fraction digits - Stack Overflow
The correct way to do it when using Intl.NumberFormat is to set both maximumFractionDigits and minimumFractionDigits options in constructor ...
Read more >Number.prototype.toLocaleString() - JavaScript | MDN
This tests for a global Intl object, checks that it's not null and that it has a NumberFormat property that is a function....
Read more >The Complete Guide to Localizing your App with JavaScript's ...
The JavaScript Internationalization API (i18n) can help localize your site or app and increase its exposure to massive global populations ...
Read more >useNumberField – React Aria
Provides the behavior and accessibility implementation for a number field component. Number fields allow users to enter a number, and increment or decrement...
Read more >babel/polyfill
As of Babel 7.4.0, this package has been deprecated in favor of directly including `core-js/stable` (to polyfill ECMAScript features):
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It appears you need to pass amaximumFractionDigits
and aminimumFractionDigits
when dealing with the polyfill. The work around is the pass both max and min:I’ve created an issue downstream in the Intl polyfill. Hopefully my workaround will suffice until it gets resolved. It’s entirely possible that the spec was implemented correctly in the Polyfill and not correctly implemented in the browser API.Thanks for reporting.
Just in case if someone else is facing the same issue. I got the right result with the following options:
Intl.NumberFormat('pt-BR', { maximumFractionDigits: 2, minimumFractionDigits: 2, style: 'currency', currency: 'BRL' }).format(444.3)