Skip to content

fix(number-format): honor min/max-fraction-digits of 0#13697

Open
spokodev wants to merge 1 commit into
mapbox:mainfrom
spokodev:w33/mapbox-number-format-zero-fraction
Open

fix(number-format): honor min/max-fraction-digits of 0#13697
spokodev wants to merge 1 commit into
mapbox:mainfrom
spokodev:w33/mapbox-number-format-zero-fraction

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026

Copy link
Copy Markdown

The number-format expression dropped min-fraction-digits and
max-fraction-digits when they were set to 0.

At parse time the option is read with a truthiness check:

if (options['max-fraction-digits']) { ... }

0 is a valid value (the style spec documents max-fraction-digits as the
maximum number of fractional digits, and 0 is in range), but it is falsy, so
the option was silently ignored and never passed to the formatter.

Concrete case: ["number-format", 3.7, {"max-fraction-digits": 0}] returned
"3.7" instead of "4". Formatting a value as an integer is a common need for
style authors, and they got the wrong label text with no error.

The fix checks !== undefined for the two numeric options. String options are
left unchanged.

Added an expression test covering max-fraction-digits of 0.

@spokodev spokodev requested a review from a team as a code owner July 2, 2026 12:17
@spokodev spokodev requested review from underoot and removed request for a team July 2, 2026 12:17
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Hey, @spokodev 👋 Thanks for your contribution to Mapbox GL JS!

Important: This repository does not accept direct merges. All changes go through our internal review process.

What happens next:

  1. A team member will review your PR here first
  2. If it looks good, they will import it to our internal repository for further review
  3. If approved, changes will be synced back here via our release process

Please respond to any review comments on this PR. For more details, see CONTRIBUTING.md.

@CLAassistant

CLAassistant commented Jul 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants