@@ -1002,29 +1002,31 @@ Inheriting Counters</h4>
10021002 To <dfn>inherit counters</dfn>
10031003 into an |element|:
10041004
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.
10071008
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.
10121013
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|.
10181021
10191022 4. Let |value source| be the [=CSS counters set=]
10201023 of the element immediately preceding |element| in [=tree order=] .
10211024
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=] .
10281030 </div>
10291031
10301032 <div class='example' id='counter-inheritance-example'>
0 commit comments