Skip to content

[cssom] How should extremely small <number>s be serialized? #2330

@csnardi

Description

@csnardi

According to https://drafts.csswg.org/cssom/#serializing-css-values:

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.

However, what should this return? (see https://jsfiddle.net/ko5k3uxx/1/)

div.style.opacity = "1e-8";
div.style.opacity;

In Firefox, the answer is 1e-8; in Chrome, 1e-08; and in Edge, 1e-008. Clearly, scientific notation is being used, but even if it wasn't, the correct answer per the spec would probably be 0, if I read that text correctly (it should probably be reworded, as "decimals" is slightly unclear -- I assume it means "numbers after the decimal point"). However, this wouldn't round trip the value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions