Skip to content

[cssom] Serialization of large numbers should use scientific notation #6471

Open
@achristensen07

Description

@achristensen07

https://drafts.csswg.org/cssom/#serialize-a-css-component-value in the section has a note that says "scientific notation is not used." While this makes sense for small values so we serialize "0" instead of "6.123233995736766e-17" and this matches the behavior of Chrome and Firefox and I'm looking into implementing this in WebKit, for large numbers all browsers do use scientific notation, as illustrated by this simple example:

<body onload='checkLargeValues()'>
<script>
function checkLargeValues() {
    let target = document.getElementById('p');
    target.style['line-height'] = 1e+26;
    alert(window.getComputedStyle(target)['line-height'])
}
</script>
<p id="p"></p>
</body>

The phrase "in the shortest form possible" is already in the text, which suggests to me that multiple forms are possible. I suggest the note be clarified to say something like "scientific notation is not used with negative exponents."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions