Skip to content

Commit 5902e88

Browse files
authored
[css-lists] Fix reversed counters to count how many elements increment or set the counter (w3c#6297)
1 parent 518bb8b commit 5902e88

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

css-lists-3/Overview.bs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,29 @@ Instantiating Counters</h4>
11421142

11431143
When a [=counter=] is [=instantiated=] without an initial value,
11441144
the user agent must dynamically calculate the initial value at layout-time
1145-
to be the number of elements and pseudo-elements that [=instantiate=] the same counter in the same [=scope=], plus 1.
1145+
to be the value returned by the following algorithm:
1146+
1147+
1. Let |num| be 0.
1148+
1149+
2. Let |first| be true.
1150+
1151+
3. For each element or pseudo-element |el| that increments or
1152+
sets the same counter in the same [=scope=]:
1153+
1154+
1. Let |incrementNegated| be |el|'s 'counter-increment' integer value for this counter,
1155+
multiplied by -1.
1156+
1157+
2. If |first| is true,
1158+
then add |incrementNegated| to |num| and
1159+
set |first| to false.
1160+
1161+
3. If |el| sets this counter with 'counter-set',
1162+
then add that integer value to |num| and
1163+
break this loop.
1164+
1165+
4. Add |incrementNegated| to |num|.
1166+
1167+
4. Return |num|.
11461168

11471169
Note: Only [=reversed=] counters can be instantiated without an initial value.
11481170

0 commit comments

Comments
 (0)