[csswg-drafts] [css-typed-om-1] How should leading whitespace before var() be normalized in CSSUnparsedValue round-tripping? (#13792)

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

== [css-typed-om-1] How should leading whitespace before var() be normalized in CSSUnparsedValue round-tripping? ==
There appears to be an interop mismatch between engines when setting a value with **two leading spaces** before a `var()` reference via Typed OM.

Consider:

```js
document.body.attributeStyleMap.set(
  'width',
  new CSSUnparsedValue(['  ', new CSSVariableReferenceValue('--A')])
);

console.log('|' + document.body.style.width + '|');
console.log('|' + document.body.attributeStyleMap.get('width') + '|');
```

Current behavior differs across engines:

* **Chrome**

  * `style.width` -> `"| var(--A)|"`
  * `attributeStyleMap.get('width')` -> `"| var(--A)|"`

* **Safari**

  * `style.width` -> `"|  var(--A)|"`
  * `attributeStyleMap.get('width')` -> `"| var(--A)|"`

* **Firefox** (in progress)

  * `style.width` -> `"|var(--A)|"`
  * `attributeStyleMap.get('width')` -> `"|var(--A)|"`

So for the initial string segment `'  '` (two spaces), engines currently:

* preserve it exactly,
* collapse it to a single space,
* or remove it entirely.

For comparison, plain CSSOM string assignment:

```js
document.body.style.width = "  var(--A)";
console.log('|' + document.body.style.width + '|');
```

serializes as:

```js
"|var(--A)|"
```

in all tested browsers.

It seems browsers should consistently normalize leading whitespace in this case, matching CSSOM string parsing/serialization behavior.


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


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

Received on Friday, 10 April 2026 14:18:35 UTC