[csswg-drafts] [css-syntax-3][cssom-1] Escape custom property name (#11729)

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

== [css-syntax-3][cssom-1] Escape custom property name ==
<details>
<summary>A declaration name is an <code>&lt;ident-token&gt;</code> representing <i>unescaped</i> code points.</summary>
<br>
It is first tokenized as an ident-like token...

  > **ident-start code point** Reconsume the current input code point, consume an ident-like token, and return it.

https://drafts.csswg.org/css-syntax-3/#consume-token

... by consuming code points as an ident sequence...

  > This section describes how to consume an ident-like token [...].
  >
  > Consume an ident sequence, and let `string` be the result.

https://drafts.csswg.org/css-syntax-3/#consume-ident-like-token

... which consumes escaped code points and gather the result...

  > **the stream starts with a valid escape** Consume an escaped code point. Append the returned code point to `result`.

https://drafts.csswg.org/css-syntax-3/#consume-an-ident-sequence

... then a declaration is consumed with `<ident-token>` as its name:

  > 1. If the next token is an `<ident-token>`, consume a token from `input` and set `decl`'s name to the token’s value.

https://drafts.csswg.org/css-syntax-3/#consume-declaration

</details>

But it is not escaped during [serialization](https://drafts.csswg.org/cssom-1/#serialize-a-css-declaration), which is required for custom properties:

```html
<style>style { --a\ b: 1 }</style>
<script>
  document.styleSheets[0].cssRules[0].cssText // style { --a\ b: 1 }
</script>
```

It could also be representing unescaped code points in [consuming a declaration](https://drafts.csswg.org/css-syntax-3/#consume-declaration).

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


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

Received on Monday, 17 February 2025 09:23:50 UTC