Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-counter-styles] Clarify what to do when 'symbols' has only one symbol for 'alphabetic' and 'numeric' systems? #5698

Closed
xiaochengh opened this issue Nov 5, 2020 · 8 comments
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-counter-styles-3 Current Work

Comments

@xiaochengh
Copy link
Contributor

The current spec says:

The @counter-style rule must have a valid symbols descriptor...; otherwise, the @counter-style does not define a counter style (but is still a valid at-rule).

Some counter systems specify that the symbols descriptor must have at least two entries. If the counter style’s system is such, and the symbols descriptor has only a single entry, the descriptor is invalid and must be ignored.

What exactly does "the descriptor is invalid and must be ignored mean"?

Example:

@counter-style foo {
  system: alphabetic;
  symbols: 'A' 'B';
  symbols: 'X';
}

There are two possible way to interpret the spec:

  1. This is a parse failure of the declaration, and the previous symbols declaration should be used. So we end up using symbols: 'A' 'B'. This is difficult to implement, though, as the parsing of one descriptor will depend on another descriptor. I'm not sure if anywhere else in CSS has such behavior.

  2. The parsing of symbols strictly follows the syntax <symbol>+, so that we end up using symbols: 'X'. It has one symbol, and therefore the @counter-style does not define a counter style. This is Firefox's current behavior


I suggest we revise the spec and clarify that we follow the second behavior, because it's the only implemented behavior, and it's easier to implement.

@tabatkins
Copy link
Member

My intention was "parse failure" (that's how that phrasing is consistently interpreted everywhere), but I'm okay with changing to Firefox's behavior and making the spec clearer in that regard.

@Loirooriol
Copy link
Contributor

I guess an analogous example is https://drafts.css-houdini.org/css-properties-values-api/#initial-value-descriptor

@property --foo {
  syntax: "<length>";
  inherits: false;
  initial-value: 1px;
  initial-value: 1;
}

where the initial-value: 1 is invalid according to the syntax: "<length>" grammar. Then the entire @property rule is invalid, it doesn't fall back to initial-value: 1px.

@tabatkins
Copy link
Member

Yeah true, so indeed, let's make the whole @counter-style rule invalid as well.

@xiaochengh
Copy link
Contributor Author

Is there a difference between "making the whole @counter-style rule invalid" and "the @counter-style rule does not define a counter style"?

According to #1862, they make a difference in whether the rule appears in OM. If so, making the rule not define a counter style seems more reasonable.

@tabatkins
Copy link
Member

Oooh, that's a good question. @Property currently says it makes the rule invalid, which presumably means it doesn't show up in the OM. I don't have time to test whether that actually happens atm, but we shoudl be consistent between these two.

@Loirooriol
Copy link
Contributor

Shows up in the OM: test

@andruud
Copy link
Member

andruud commented Nov 12, 2020

I suggest we revise the spec and clarify that we follow the second behavior, because it's the only implemented behavior, and it's easier to implement.

+1, we should avoid parse-time behavior of one descriptor being affected by another descriptor, any complicated "validation" of the rule as a whole should happen at "@-rule interpretation time" (or whatever we want to call that). I didn't even raise an issue for this for @property, I thought it was a given. 🤷‍♂️

@tabatkins
Copy link
Member

Makes sense, I've clarified that paragraph that failing to meet the minimum symbols length just means you don't define a counter style; nothing is invalid.

@tabatkins tabatkins added Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. and removed Needs Edits labels May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-counter-styles-3 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants