Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: src/i18n.js

Issue 1231613006: Make NumberFormat use the ICU currency data, fix bug in NumberFormat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use short form of license Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/i18n.js
diff --git a/src/i18n.js b/src/i18n.js
index a4556c75637006135575d9f0849f75e1cdc8edd1..6b6d4afa63b43f2495068abf9c691818eb7d1f39 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -1099,11 +1099,19 @@ function initializeNumberFormat(numberFormat, locales, options) {
var mnid = getNumberOption(options, 'minimumIntegerDigits', 1, 21, 1);
defineWEProperty(internalOptions, 'minimumIntegerDigits', mnid);
- var mnfd = getNumberOption(options, 'minimumFractionDigits', 0, 20, 0);
- defineWEProperty(internalOptions, 'minimumFractionDigits', mnfd);
+ var mnfd = options['minimumFractionDigits'];
+ var mxfd = options['maximumFractionDigits'];
+ if (!IS_UNDEFINED(mnfd) || !internalOptions.style === 'currency') {
+ mnfd = getNumberOption(options, 'minimumFractionDigits', 0, 20, 0);
+ defineWEProperty(internalOptions, 'minimumFractionDigits', mnfd);
+ }
- var mxfd = getNumberOption(options, 'maximumFractionDigits', mnfd, 20, 3);
- defineWEProperty(internalOptions, 'maximumFractionDigits', mxfd);
+ if (!IS_UNDEFINED(mxfd) || !internalOptions.style === 'currency') {
+ mnfd = IS_UNDEFINED(mnfd) ? 0 : mnfd;
+ fallback_limit = (mnfd > 3) ? mnfd : 3;
+ mxfd = getNumberOption(options, 'maximumFractionDigits', mnfd, 20, fallback_limit);
+ defineWEProperty(internalOptions, 'maximumFractionDigits', mxfd);
+ }
var mnsd = options['minimumSignificantDigits'];
var mxsd = options['maximumSignificantDigits'];
@@ -1157,8 +1165,6 @@ function initializeNumberFormat(numberFormat, locales, options) {
internalOptions,
resolved);
- // We can't get information about number or currency style from ICU, so we
- // assume user request was fulfilled.
if (internalOptions.style === 'currency') {
ObjectDefineProperty(resolved, 'currencyDisplay', {value: currencyDisplay,
writable: true});

Powered by Google App Engine
This is Rietveld 408576698