Don't use "percentSign" when unit=percent in Intl.NumberFormat
Categories
(Core :: JavaScript: Internationalization API, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox74 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(3 files)
[...] the values within the "percent" field must also contain the substring "{percentSign}"; [...]; and the values within the "unit" field must also contain one of the following substrings: "{unitSymbol}", "{unitNarrowSymbol}", or "{unitName}".
So when style=unit, one of "{unitSymbol}", "{unitNarrowSymbol}", or "{unitName}" must be present. And per https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_proposed_out.html#sec-partitionnumberpattern, the output must then contain a type=unit element. Contrary to that, we're emitting a type=percentSign element.
js> new Intl.NumberFormat("en-US", { style: "unit", unit: "percent" }).formatToParts(0)
[{type:"integer", value:"0"}, {type:"percentSign", value:"%"}]
Assignee | ||
Comment 1•4 years ago
|
||
Adds a separate FormattedRelativeTimeToParts function to avoid having to add
another one-off argument to the existing intl::FormattedNumberToParts function.
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Moving GetFieldTypeForNumberField outside of NumberFormatFields::append let's us
avoid adding another flag to NumberFormatFields in the next part.
Depends on D60966
Assignee | ||
Comment 3•4 years ago
|
||
Depends on D60968
Pushed by btara@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4f0bdc386a85 Part 1: Create a separate FormattedRelativeTimeToParts function. r=jwalden https://hg.mozilla.org/integration/autoland/rev/177fd2d58046 Part 2: Move GetFieldTypeForNumberField out of NumberFormatFields::append. r=jwalden https://hg.mozilla.org/integration/autoland/rev/236b8297fd5d Part 3: Pass through a boolean flag to detect style=unit number formatters. r=jwalden
Comment 5•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4f0bdc386a85
https://hg.mozilla.org/mozilla-central/rev/177fd2d58046
https://hg.mozilla.org/mozilla-central/rev/236b8297fd5d
Description
•