Re: [csswg-drafts] [css-variables] Custom properties should *not* serialize "exactly as specified" (#7329)

  > we should close open constructs

Not sure if "open constructs" encompass a trailing reverse solidus:

```js
style.setProperty('--a', '\\')
style.setProperty('--b', '1')
style.cssText; // --a: \; --b: 1;
```

Could a tokenizer switch, like for `<unicode-range-token>`, do the trick?

```diff
  If decl’s name is a custom property name string,
- then set decl’s original text
- to the segment of the original source text string
- corresponding to the tokens of decl’s value.
+ then consume the value of a custom property
+ from the segment of the original source text string
+ corresponding to the tokens of decl’s value,
+ and set decl’s value to the result.
```

*Consume the value of a custom property* would invoke the tokenizer with `close open constructs` set to true and open constructs would be closed in the appropriate tokenizer algorithms.

Implementations could store the declaration value as a list of tokens or as their serialization.

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


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

Received on Tuesday, 19 August 2025 13:04:47 UTC