Re: [csswg-drafts] [cssom] Serialize numbers using scientific notation? (#8538)

Just to redocument the behavior between browsers currently, [here's a testcase](https://software.hixie.ch/utilities/js/live-dom-viewer/?saved=12767):

<details><summary>code</summary>

```html
<!DOCTYPE html>
<div id=test></div>
<table id=results>
<thead><tr><th>JS Value<th>Specified<th>Computed</thead>
</table>
<script>
var test = document.querySelector("#test");
function addRow(...cells) {
 var tr = document.createElement("tr");
 for(var cell of cells) {
  var td = document.createElement("td");
  td.textContent = cell;
  tr.appendChild(td);
 }
 document.querySelector("#results").appendChild(tr);
}

for(var i = 0; i < 10; i++) {
 var value = .123456789 / Math.pow(10, i);
 test.style.opacity = value;
 addRow(value, test.style.opacity, getComputedStyle(test).opacity);
}
</script>
<style>
table {
 border-collapse: collapse;
}
td {
 border: thin solid silver;
 padding: 1px 5px;
}
</style>
```
</details>

The results are different between all three major engines:

1. Blink: retains six significant figures (aka `.000123457`), switches to scinot at e-5.
2. Gecko: retains six significant figures, switches to scinot at e-7.
3. WebKit: retains six figures after the decimal point (aka `.000123`), never switched to scinot. (At e-7 it just prints as `0`)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8538#issuecomment-2140904651 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 30 May 2024 21:39:42 UTC