Reading `opacity` back from `getComputedStyle` results in a value that is not the value specified.
var el = document.body;
el.style.opacity = '0.95'; // Specified value.
el.style.opacity;// Specified value returned.
getComputedStyle(el).opacity; // Not the specified value.
With getComputedStyle(el).opacity, an internal number of the opacity is returned. Is it that '9.5' sets the opacity as a (lossy) binary number, which, when returned, is converted to a string?
Css3 spec says that the value returned must be "The same as the specified value after clipping the <alphavalue> to the range [0.0,1.0]."
Since the value returned ("0.949999988079071") is not the specified value ("9.5"), then this is a violation of a spec.
| Computed value: The same as the specified value
| after clipping the <alphavalue> to the range [0.0,1.0].
Version 5.1.1 (6534.51.22)
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22"
> Is it that '9.5' sets the opacity as a (lossy) binary number, which, when returned, is converted to a string?
Yes. As such, this really is the specified value, and no specs have been violated.
But perhaps there is something to do here that would swipe this under the carpet (like switching from float to double?), or something else I'm unaware of. So, keeping the bug open for experts to consider.
I think some floating point rounding is acceptable, so I don't think this is a bug. <http://dev.w3.org/csswg/css3-values/#numeric-types> says "UAs should support reasonably useful ranges and precisions".
So 9.5., specified value, is out of reasonably useful?
Correction: ".95", not "9.5".