w3c / w3c/csswg-drafts

[css-syntax][cssom][css-values] Asymmetry of parsing and serializing numbers

Open
#5,880 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

css-syntax-3 cssom-1
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

According to [css-syntax]4.3.12.&4.3.13. as well as [css-values]5. numbers are parsed and processed with the maximum possible precision.
However, [cssom]6.7.2. specifies a maximum precision of 6 digits (7th for rounding) for serialization.

So serializing and re-parsing can change values. For example, JavaScript modifications of style sheets can have unexpected and unavoidable side-effects.

To demonstrate a worst-case: image-orientation:44.99999deg computes to 0deg, but after serialization and re-parsing computes to 90deg, as it was rounded to 45deg.

So the question is: Should parsing also limit precision or is there a different solution?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked CSS Syntax, CSS Values, and CSSOM sections and compare their requirements for parsing, computation, and serialization precision. Determine whether the working group should change parsing or serialization rules; done requires an agreed resolution and corresponding updates to the affected specification text.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.