Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: formatter.formatToParts is not a function in older browsers #922

Open
alexcroox opened this issue Jun 16, 2020 · 5 comments
Open
Labels
Status: PR Welcome Welcome to Pull Request Type: Bug Bug or Bug fixes

Comments

@alexcroox
Copy link

vue & vue-i18n version

"vue-i18n": "^8.18.1",
"vue": "^2.6.11",

Older browsers such as Chrome 50 are erroring with: TypeError: formatter.formatToParts is not a function

Which relates to VueI18n.prototype._ntp

var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
var ret = formatter && formatter.formatToParts(value);

Is there anything specific I can do to pollyfill this? I've tried adding:

transpileDependencies: ['vue-i18n'] with no joy

@alexcroox
Copy link
Author

alexcroox commented Jun 16, 2020

I've just done some more digging, Intl: NumberFormat: formatToParts has no pollyfills. So this library won't work with IE11 or iOS 11 or iOS 12 if you want to use i18n-n

https://caniuse.com/#feat=mdn-javascript_builtins_intl_numberformat_formattoparts

@exoego exoego added the Type: Bug Bug or Bug fixes label Jul 1, 2020
@exoego
Copy link
Collaborator

exoego commented Jul 1, 2020

Oops...
IE11 is one of supported browser of vue-i18n (ref. #843, #844), so this is definitely bug.
formatter.formatToParts should be replaced with polyfill.

@alexcroox
Copy link
Author

I don't believe there is one for formatToParts.

@exoego
Copy link
Collaborator

exoego commented Jul 1, 2020

According to MDN, a github repository https://github.com/tc39/proposal-intl-formatToParts provides polyfill for formatToParts.
PRs are welcome.

@exoego exoego added the Status: PR Welcome Welcome to Pull Request label Jul 1, 2020
@alexcroox
Copy link
Author

Sorry I wasn't clear, see this issue from that repo: tc39/proposal-intl-formatToParts#4

Current polyfill contains only Intl.DateTimeFormat.prototype.formatToParts but not Intl.NumberFormat.prototype.formatToParts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: PR Welcome Welcome to Pull Request Type: Bug Bug or Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants