Skip to content

[css-syntax-3][cssom-1] Escape custom property name #11729

@cdoublev

Description

@cdoublev
A declaration name is an <ident-token> representing unescaped code points.
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

But it is not escaped during serialization, which is required for custom properties:

<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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions