-
Notifications
You must be signed in to change notification settings - Fork 717
[css-lists] Algorithm for initial counter value in reversed list should repeat the last increment instead of the 1st one #6797
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
Comments
I'm in favor of this change. I think it makes slightly more sense to use the last (non-zero) increment than the first. FYI, I'm correcting the existing tests (as if the proposal here is adopted) and adding a ton of new WPTs in: Here's the paths to the new tests in case you want to reference them in the spec: I'm also amending these tests to check the syntax: I'll wait for a resolution before landing that... |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> Topic: Initial Counter Value of reversed list and increments<fantasai> github: https://github.com//issues/6797 <fantasai> oriol: Define reversed counters <fantasai> oriol: either specify start explicitly or calculate automatically <fantasai> oriol: I think algorithm doesn't make sents <fantasai> oriol: if don't have any counter-set, some of the increments of the items for the counter <fantasai> oriol: but first increment is counted twice, not once <fantasai> oriol: and then sum is adjusted by -1 to get start value <fantasai> oriol: counting the first increment twice, the reason might be otherwise last item will have value of ?? <fantasai> oriol: but in case of -1, we want the last item to get a value of 1 <fantasai> oriol: if all increments are the same <fantasai> oriol: when they are different, I think we should actually repeat the last increment <fantasai> oriol: I have some examples in the issue <fantasai> oriol: if list with all increments -1 <fantasai> oriol: and take one item in middle of list to -2, this only affects preceding items <fantasai> oriol: but if we change first item, this will affect the value of the last item <fantasai> oriol: and modify all values in the list <fantasai> oriol: which seems unexpected <fantasai> oriol: another issue with counter-set, you have some increment there and the with counter-set <fantasai> oriol: start without counter-set, and item with value 2 <fantasai> oriol: and then we assign counter-set: 2 <fantasai> oriol: this should have no effect <fantasai> oriol: probably it's what the author expects <fantasai> oriol: with current spec this can have an effect <fantasai> oriol: in issue itself I proposed how to update the spec <fantasai> oriol: Also variant of spec text taking into account resolution from 6738 <fantasai> oriol: where we decided to skip elements that are hidden <fantasai> oriol: so only non-zero increments <fantasai> oriol: Mats said it makes sense <fantasai> oriol: and he already has an implementation <Rossen_> q? <fantasai> oriol: so suggest to take this change <fantasai> Rossen_: sounds like a reasonable change, any others with an opposing opinion? <fantasai> [silence] <TabAtkins> +1 btw <fantasai> Rossen_: objections? <fantasai> RESOLVED: Accept proposal <TabAtkins> (i assumed this was gonna be included in the issue we talked about during the f2f last week) |
https://drafts.csswg.org/css-lists/#instantiating-counters
Problem 1: the value of the last item is the increment of the 1st one.
Let's consider this basic list:
The initial value is 5 which is the sum of the counter-increments, with the 1st one counted twice. The result looks good.
Then, let's change one increment in the middle:
Only the preceding elements are affected, as expected. But now let's undo and change the first increment instead:
Now all the values changed! That's because, by counting the 1st increment twice, the value of the last item will precisely be the increment of the 1st item (assuming there is no
counter-set
). This doesn't seem to make much sense.Problem 2:
counter-set
to the current value affects preceding valuesLet's consider, again,
and then add a
counter-set: list-item 2
to the item that already had value 2:Seems unexpected that when setting the counter to the same value that it would have without
counter-set
, the values of the preceding items change. Basically, instead of using thecounter-increment
of the 3rd item as the difference between the 2nd and 3rd items, it's using the counter-increment of the 1st item!Solution: use the last increment twice, instead of the 1st one
The algorithm should probably be more like:
num
be 0.incrementNegated
be 0.el
that increments or sets the same counter in the same scope:incrementNegated
toel
’scounter-increment
integer value for this counter, multiplied by -1.el
sets this counter withcounter-set
, then add that integer value tonum
and break this loop.incrementNegated
tonum
.incrementNegated
tonum
.num
.Or, taking #6738 into account, repeat the last non-zero increment:
num
be 0.lastNonZeroIncrementNegated
be 0.el
that increments or sets the same counter in the same scope:incrementNegated
toel
’scounter-increment
integer value for this counter, multiplied by -1.incrementNegated
is not zero, setlastNonZeroIncrementNegated
toincrementNegated
.el
sets this counter withcounter-set
, then add that integer value tonum
and break this loop.incrementNegated
tonum
.lastNonZeroIncrementNegated
tonum
.num
.Then we would have:
The text was updated successfully, but these errors were encountered: