@@ -1002,29 +1002,31 @@ Inheriting Counters</h4>
1002
1002
To <dfn>inherit counters</dfn>
1003
1003
into an |element|:
1004
1004
1005
- 1. Let |element counters| be an initially empty [=CSS counters set=]
1006
- representing |element|’s own [=CSS counters set=] .
1005
+ 1. If |element| is the [=tree/root=] of its document tree,
1006
+ the element has an initially-empty [=CSS counters set=] .
1007
+ Return.
1007
1008
1008
- 2. If |element| is the [=tree/root=] of its document tree ,
1009
- return.
1010
- (The element has an initially-empty counter map
1011
- and inherits nothing.)
1009
+ 2. Let |element counters| ,
1010
+ representing |element|’s own [=CSS counters set=] ,
1011
+ be a copy of the [=CSS counters set=]
1012
+ of |element|'s parent element.
1012
1013
1013
- 3. Let |counter source| be the [=CSS counters set=]
1014
- of |element|’s preceding sibling,
1015
- if it has one,
1016
- or else of |element|’s parent
1017
- if it does not.
1014
+ 3. Let |sibling counters| be the [=CSS counters set=]
1015
+ of |element|'s preceding sibling (if it has one),
1016
+ or an empty [=CSS counters set=] otherwise.
1017
+
1018
+ [=map/For each=] |counter| of |sibling counters|,
1019
+ if |element counters| does not already contain a counter with the same [=name=] ,
1020
+ append a copy of |counter| to |element counters|.
1018
1021
1019
1022
4. Let |value source| be the [=CSS counters set=]
1020
1023
of the element immediately preceding |element| in [=tree order=] .
1021
1024
1022
- 5. [=map/For each=] (|name|, |originating element|, |value|) of |value source|:
1023
- 1. If |counter source| also [=set/contains=] a [=counter=]
1024
- with the same |name| and |originating element|,
1025
- then [=set/append=] a copy of |value source|’s [=counter=]
1026
- (|name|, |originating element|, |value|)
1027
- to |element counters|.
1025
+ [=map/For each=] |source counter| of |value source|,
1026
+ if |element counters| [=set/contains=] a [=counter=]
1027
+ with the same [=name=] and [=creator=] ,
1028
+ then set the the [=value=] of that counter
1029
+ to |source counter|'s [=value=] .
1028
1030
</div>
1029
1031
1030
1032
<div class='example' id='counter-inheritance-example'>
0 commit comments