w3c / w3c/csswg-drafts

[cssom] Should <number> be serialized using scientific notation?

Open
#3,276 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In [1], the serialization of scientific notation for <number>, it says:

A base-ten number using digits 0-9 (U+0030 to U+0039) in the shortest form possible, using "." to separate decimals (if any), rounding the value if necessary to not produce more than 6 decimals, preceded by "-" (U+002D) if it is negative.

Note: scientific notation is not used.

I think this is a little bit ambiguous for scientific notation. For a very long number, like a max float (3.40282e+38), all the browsers (i.e. Chrome, Firefox, Safari) still serialize the scientific notation.
e.g.

div {
  animation-timing-function: cubic-bezier(0, 3.40282e+38, 0, 0);
}
console.log(window.getComputedStyle(div).animationTimingFunction); // the output is "cubic-bezier(0, 3.40282e+38, 0, 0)" in all the browsers.

Just want to know should we update the spec or all the implementations of browser are incorrect?
Besides, if we want to update the spec, should we use "+" sign in scientific notation? (i.e. Use 3.40282e38, instead of 3.40282e+38, because shorter serialization is preferred.)

[1] https://drafts.csswg.org/cssom/#serializing-css-values

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

Read the CSSOM “serializing CSS values” section linked in the issue, then compare its scientific-notation wording with the reported computed-style behavior in Chrome, Firefox, and Safari. Done means resolving whether the specification or implementations are incorrect and documenting the decision, including whether a plus sign is required in the notation.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.