Safari 14 Intl.NumberFormat usage throwing "Error: locale data nu must be an object"
See original GitHub issueBug Report
What
Trying to initialize an Intl.NumberFormat
object in Safari 14 with the latest version of the polyfill loaded throws an exception.
Details
Browser Safari (Desktop) Version 14.0 (15610.1.28.1.9, 15610)
Minimal code example https://jsbin.com/xikuwesiru/edit?html,console
<script src="https://polyfill.io/v3/polyfill.min.js?features=Intl.~locale.ja" crossorigin></script>
<script>
const nf = new Intl.NumberFormat();
console.log(nf.format(1e3));
</script>
Expected result
Console logs: 1,000
Actual result
Error: locale data nu must be an object
is thrown.
Possible workaround for users of pollyfill.io service Set the library to an earlier version without these polyfills: (i.e. https://polyfill.io/v3/polyfill.min.js?features=Intl.~locale.ja&version=3.89.4)
More info
- Saw it first time in the latest
polyfill-service
release - There’s some indications this doesn’t happen on Safari 13, but hard to validate.
- Safari 14 doesn’t need this polyfill? (https://kangax.github.io/compat-table/esintl/#safari14)
- Seems gated vs non-gated doesn’t make a difference.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Intl.NumberFormat() constructor - JavaScript - MDN Web Docs
The Intl.NumberFormat() constructor creates Intl.NumberFormat objects that enable language-sensitive number formatting.
Read more >Why doesn't Intl.NumberFormat work with units in Safari and ...
The problem comes from the value unit of the style field. According to ECMA-402, 6th edition, June 2019 ECMAScript® 2019 ...
Read more >Generated Content by David Storey - RSSing.com
These share a common parent Intl object. One way to localise a string, number, or date is to use the relevant object's constructor,...
Read more >Number.prototype.toLocaleString() - JavaScript
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 >How To Correctly Polyfill Intl Locale Data - ADocLib
Returns a new object with properties reflecting the locale and collation ... Safari 14 Intl.NumberFormat usage throwing Error: locale data nu must be...
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
@longlho and @romainmenke thank you for taking the time to handle this issue 👍
I have the same issue in Safari 13 with
RelativeTimeFormat
and fixing the version to3.89.4
(I tried every versions between3.89.4
&3.96.0
) also fixed the issue.