Skip to content

Filters: number() and bytes() with locale round half up like without locale - #427

Closed
vosikar wants to merge 2 commits into
nette:masterfrom
vosikar:fix/number-bytes-rounding
Closed

vosikar wants to merge 2 commits into
nette:masterfrom
vosikar:fix/number-bytes-rounding

Conversation

@vosikar

@vosikar vosikar commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

With a locale set |number and |bytes use NumberFormatter, which rounds half-even by default. Without a locale the number_format() / round() is used, which rounds half away from zero. The formatter now uses ROUND_HALFUP, so both round the same way. Covered by new tests.

{9.105|number:2} {* 9.11 without locale, 9,10 with cs *}

dg and others added 2 commits July 31, 2026 19:48
…boolean attributes (BC break)

None of them is a boolean attribute in HTML; they are enumerated ones, so
rendering them as a bare name was wrong in three separate ways:

- a string 'false' is truthy in PHP, so contenteditable={$s} rendered the
  attribute present, i.e. the exact opposite of what was asked for
- the empty value is not a keyword of draggable, it maps to the invalid value
  default 'auto', so draggable=true could not be expressed at all
- 'attribute missing' and 'attribute false' are different states; the false
  value is what disables editing inside a contenteditable region, and dropping
  the attribute silently inherited from the parent instead

Two new categories replace them. 'tristate' (contenteditable, draggable,
spellcheck, writingsuggestions) maps bool to the true/false keywords, exactly
like aria-* already does, so formatAriaAttribute now delegates to it. The
'valuedBool' one (hidden, popover) stays a flag but keeps a non-empty value,
so hidden="until-found" survives. Falsy values are tested first there: hidden
with a '0' coming from a database must not render hidden="0", which is an
invalid value and would map back to the hidden state.
…locale, instead of NumberFormatter's default half-even
@vosikar vosikar changed the title Filters: number() and bytes() with locale round half up like without … Filters: number() and bytes() with locale round half up like without locale Sep 30, 2026
@dg
dg force-pushed the master branch 2 times, most recently from 02b2c13 to c169e13 Compare October 22, 2026 00:10
@dg dg mentioned this pull request Oct 28, 2026
@dg

dg commented Oct 29, 2026

Copy link
Copy Markdown
Member

Thanks, merged!

@dg dg closed this Oct 29, 2026
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