Skip to content

Use tabular numerals for ticking duration and elapsed formats - #392

Open
Goldloli wants to merge 1 commit into
github:mainfrom
Goldloli:tabular-nums-for-ticking-formats
Open

Goldloli wants to merge 1 commit into
github:mainfrom
Goldloli:tabular-nums-for-ticking-formats

Conversation

@Goldloli

Copy link
Copy Markdown

Fixes #383

Description

A ticking format="duration" / format="elapsed" element visibly jumps around as it counts, because proportional digits change width between ticks. The rendered span[part="root"] now gets font-variant-numeric: tabular-nums for those two formats, following the write-skipping pattern of #updateRenderRootContent — the inline style is only written when its value actually changes, so the periodic-tick fast path is untouched.

  • Other formats get no inline style at all, exactly as before.
  • The default stays overridable: ::part(root) { font-variant-numeric: normal !important } (an author !important rule beats a non-important inline style).

Of the two shapes discussed in the issue (document a user-side rule vs make it the default), this makes it the default for the ticking formats only — the timer jumping is visible out of the box, while date/relative typography is unchanged.

Verification

  • npx web-test-runner — 640 passed, 0 failed, including two new tests: one asserts duration and elapsed render with tabular-nums and another asserts other formats get no inline numeric styling; without the change the first fails with expected '' to equal 'tabular-nums'
  • npx tsc --noEmit and npx eslint src/relative-time-element.ts test/relative-time.js — clean

@Goldloli
Goldloli requested a review from a team as a code owner October 30, 2026 17:13

This branch has not been deployed

No deployments
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.

Use tabular numbers for elapsed time (format=duration|elapsed)

1 participant