Skip to content

[css-selectors-4] Clarify the grammar of a functional pseudo-class #7016

@cdoublev

Description

@cdoublev

https://drafts.csswg.org/selectors-4/#typedef-pseudo-element-selector

<pseudo-class-selector> = ':' <ident-token> | ':' <function-token> <any-value> ')'

<function-token> is a non-preserved token, therefore there will be no <function-token> when parsing <pseudo-class-selector>. However, CSS Values allows <function-token> <any-value> ')':

I am not sure why there would be a need to represent a functional notation like this rather than only with a prose saying that it represents a function component value, or with <function>, for example.

I see the flexibility to define a function with <function-token> <number> ')' to allow an arbitrary function name accepting <number> as its argument, for example, but the root problem described above remains.

This problem also exists with <general-enclosed>, defined with [<function-token> <any-value>? )] | (<any-value>?).

There is a related (but different) problem with <attribute-selector>, which includes '[' and ']' whereas it represents a simple block associated the corresponding token. They cannot be unquoted otherwise they would represents grouping combinators, but I think it would be usefull to add a note about this.

Selector grammars also use <ident-token> and <string-token> rather than the corresponding CSS type(s).

Selectors are parsed with parse something according to a CSS grammar, which matches the given grammar against component values, not tokens, which makes a difference for functions and simple blocks.

Edited after the changes in CSS Values that allow using <function-token> in value definitions.

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