w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 664 forks source link

[css-counter-styles] How should relative-length values be interpreted when used in @counter-style descriptors? #10877

Open weinig opened 2 months ago

weinig commented 2 months ago

How should relative-length values be interpreted when used in @counter-style descriptors?

The grammars for @counter-style descriptors, for example, 'range', allow the use of relative-length values due to the fact that calc() allows for them.

For example, using 'range' again:


@counter-style a {
  range: infinite calc(3 * sign(10em - 2px));
}

So the question is, what does 10em evaluate to? @font-palette-values contains this text:

Math functions, such as calc(), and also var(), and env(), are valid within descriptor values in a @font-palette-values rule. They are evaluated within the context of the root element. Relative units are also evaluated within the context of the root element.

but I can't find any similar text for @counter-style.

fantasai commented 1 month ago

I don't think there's any real need for this, so if it's easier on implementations I think it's reasonable to disallow it.

tabatkins commented 1 month ago

I agree there's no particular use-case for it, but I do care that grammars are consistently interpreted. If we want to disallow math functions (but, presumably, allow other functions that could produce numbers, like custom env()), we should make a production with that restriction. If we want to allow only literals for some reason, we can use the <number-token> production.