[csswg-drafts] [css-typed-om-1] How should <opacity-value> percentages behave in Typed OM? (conversion vs preservation) (#13507)

janvarga has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-typed-om-1] How should <opacity-value> percentages behave in Typed OM? (conversion vs preservation) ==
There appears to be an interop mismatch between engines when setting `opacity` (and `fill-opacity`) via Typed OM using percentages.

Per CSS Color 4:

> "Opacity values outside the range [0,1] are not invalid, and are preserved in specified values, but are clamped to the range [0, 1] in computed values."

However, opacity is defined as `<opacity-value>`, which allows `<number>` or `<percentage>`. In CSSOM, when setting via string:

```js
document.body.style.opacity = "-3.14%";
console.log(document.body.style.opacity); // "-0.0314"
```

The specified style serializes as a number (percentage converted to number).

In Typed OM:

```js
document.body.attributeStyleMap.set('opacity', new CSSUnitValue(-3.14, "percent"));
console.log(document.body.style.opacity);
console.log(document.body.attributeStyleMap.get('opacity'));
```

Current behavior differs across engines:

* Safari preserves `"-3.14%"` in both CSSOM and Typed OM.
* Chrome rejects percentage values in Typed OM (`TypeError`).
* Firefox (in progress) expects behavior consistent with CSSOM string parsing (i.e. percentage converted to number).

Questions:

What is the expected behavior for `<percentage>` values of `<opacity-value>` in Typed OM?

Specifically:

* Should percentages be accepted?
* If accepted, should they be preserved as percentages in specified style, or canonicalized to `<number>` (as CSSOM string parsing appears to do)?

Links:
- https://wpt.fyi/results/css/css-typed-om/the-stylepropertymap/properties/opacity.html?label=experimental&label=master&aligned
- https://wpt.fyi/results/css/css-typed-om/the-stylepropertymap/properties/fill-opacity.html?label=experimental&label=master&aligned

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13507 using your GitHub account


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

Received on Tuesday, 17 February 2026 11:55:57 UTC