Closed Bug 1662977 Opened 4 years ago Closed 4 years ago

Don't condition currency-formatting fractional-digits rounding behavior on the currency's default digits

Categories

(Core :: JavaScript: Internationalization API, defect, P2)

defect

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox82 --- wontfix
firefox85 --- fixed

People

(Reporter: Waldo, Assigned: anba)

Details

Attachments

(1 file)

Right now, this sensible-looking code throws:

new Intl.NumberFormat("en", { style: "currency", currency: "EUR", maximumFractionDigits: 0 });

. The problem is that when currency formatting is chosen, the minimum fractional digits in intermediate computations (if the user doesn't provide it) is determined by consulting the currency's default number of fractional digits. For most currencies, that number is 2 (USD$2.00, EUR$7.00, etc.). Because the user-supplied maximumFractionDigits is below that minimum, an error is thrown.

This is being changed so that this is allowed as long as the user-supplied digits are not inconsistent with each other. Arguably the spec change is a bug -- the above fragment works for some currencies (e.g. JPY) but not others. For our purposes, assuming the spec changes accordingly, we probably ought accordingly view this bug as a defect (and not an enhancement request).

As far as I know, no one's started work on implementing this yet, although anba has threatened to do so. I presume it won't be terribly difficult to do so, but as the Github PR is half a dozen patches not coalesced and I'm not immediately aware of a way to view a PR as a single condensed change, I can't say with absolute certainty.

Filing to get this on the radar, and for tracking purposes, mostly...

Implements the changes from the "has consensus" PR https://github.com/tc39/ecma402/pull/471.

The second pair of DefaultNumberOption() calls was inlined, because only the
fallback case is relevant anyway. Steps 12.d and 12.e from the spec PR were
combined into a single if-block. That way it also matches step 12.f more
closely.

Also changed the single if steps into an if-else if chain, because the
steps are mutually exclusive.

Depends on D95734

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:anba, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(andrebargull)
Flags: needinfo?(andrebargull)
Pushed by cbrindusan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8ec50232ea55
Allow "maximumFractionDigits" option in Intl.NumberFormat to be less than the default minimum fraction digits. r=yulia
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: