# Contact emails
jwo...@igalia.com
litt...@chromium.org
# Spec
https://github.com/tc39/ecma402/pull/79
# Summary
Intl.NumberFormat.prototype.formatToParts() is scheduled to be added to the
EcmaScript Internationalization API specification (Ecma 402). It adds a
method
to format a number to a list of tokens and their types (e.g. minusSign,
integer,
decimal, fraction, currency, percentSign, etc). It is implemented and
disabled
by default by Firefox. v8 implemented it behind a flag. See also, the
corresponding DateTimeFormat feature here:
https://www.chromestatus.com/feature/6319456309477376
# Motivation
A web form may want to display a price like "$1,234.00" with the fractional
part ".00" in superscript and in a different color. If you use
Intl.NumberFormat.prototype.format(), you get a string, which you would then
need to parse to find the fractional part. However, the decimal separator is
locale dependent, so attempting to account for this variability somewhat
defeats the purpose of the locale-independent NumberFormat API. The
solution is
to expose the individual parts of the formatted string with tags to identify
each part's role in the overall representation.
# Interoperability risk
* Firefox: In development
* Edge: No public signals
* Safari: No public signals
* Web developers: No signals
# Compatibility risk
Low compatibility risk, as this feature is exposed through a new method
`Intl.NumberFormat.prototype.formatToParts`.
# Ongoing technical constraints
None
# Will this feature be supported on all six Blink platforms (Windows,
Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
# OWP launch tracking bug
https://bugs.chromium.org/p/v8/issues/detail?id=5244
# Link to entry on the Chrome Platform Status
https://www.chromestatus.com/feature/5686840812109824