@@ -2963,26 +2963,37 @@ Tree Counting Functions: the ''sibling-count()'' and ''sibling-index()'' notatio
29632963 Like '':nth-child()'' ,
29642964 ''sibling-index()'' is 1-indexed.
29652965
2966+ Together, these are known as the <dfn>tree-counting functions</dfn> .
2967+
29662968 Note: The ''counter()'' function can provide similar abilities as ''sibling-index()'' ,
29672969 but returns a <<string>> rather than an <<integer>> .
29682970
2969- When used on an [=element-backed pseudo-element=] which is also a real element,
2970- the tree counting functions resolve for that real element. For other [=pseudo-elements=]
2971- they resolve as if they were resolved against the
2972- originating element. It follows that for nested pseudo-elements the resolution
2973- will recursively walk the originating elements until a real element is found.
2971+ When used on an [=element-backed pseudo-element=] that is also a real element,
2972+ the [=tree-counting functions=] resolve for that real element.
2973+ For other [=pseudo-elements=] ,
2974+ they resolve as if they were resolved against the [=ultimate originating element=] .
2975+
2976+
2977+ A [=tree-counting function=]
2978+ is is a type of [=tree-scoped-reference/loosely-matched=] [=tree-scoped reference=] ,
2979+ which is resolved as if the element were given an automatic [=tree-scoped name=]
2980+ that matches an identical automatic name on the [=tree-scoped reference=]
2981+ of the [=tree-counting function=] .
2982+ If the reference fails to match
2983+ (because the element is, for example, in a descendent shadow tree from the stylesheet),
2984+ the function returns 0.
29742985
2975- A tree counting function is a [=tree-scoped reference=] where it references
2976- an implicit [=tree-scoped name=] for the element it resolves against. This is
2977- done to not leak tree information to an outer [=tree=] . A tree counting
2978- function that is scoped to an outer [=tree=] relative to the element it
2979- resolves against, will alway resolve to 0.
2986+ Note: This restriction is to avoid leaking shadow tree information to outer [=trees=] .
29802987
29812988 <div class=example>
2982- Examples of how ''sibling-index()'' resolves for pseudo-elements, and when the
2983- rule and the element come from different [=trees=] :
2989+ The following examples show how ''sibling-index()'' resolves
2990+ for [=pseudo-elements=] and across [=shadow tree=] boundaries :
29842991
29852992 <pre class=lang-css>
2993+ #target {
2994+ /* Based on the sibling-index() of #target */
2995+ width: calc(sibling-index() * 10px);
2996+ }
29862997 #target::before {
29872998 /* Based on the sibling-index() of #target */
29882999 width: calc(sibling-index() * 10px);
@@ -2992,23 +3003,24 @@ Tree Counting Functions: the ''sibling-count()'' and ''sibling-index()'' notatio
29923003 width: calc(sibling-index() * 10px);
29933004 }
29943005 ::slotted(*)::before {
2995- /* Based on the sibling-index() of the slotted element - outer tree */
3006+ /* Based on the sibling-index() of the slotted element in the outer tree */
29963007 width: calc(sibling-index() * 10px);
29973008 }
29983009 ::part(my-part) {
2999- /* 0px - inner tree */
3010+ /* Returns 0px, because referencing a shadow tree */
30003011 width: calc(sibling-index() * 10px);
30013012 }
30023013 :host {
3003- /* Based on the hosts sibling-index() - outer tree */
3014+ /* Based on the host's sibling-index() in the outer tree */
30043015 width: calc(sibling-index() * 10px);
30053016 }
30063017 </pre>
30073018
30083019 </div>
30093020
3010- Note: These functions, to match [=selectors=] like '':nth-child()'' , operate on the DOM tree,
3011- rather than the [=flat tree=] like most CSS values do.
3021+ Note: Like '':nth-child()'' and other counting selectors,
3022+ the [=tree-counting functions=] operate on the DOM tree,
3023+ rather than the [=flat tree=] like most CSS operations do.
30123024 They may, in the future, have variants that support counting [=flat tree=] siblings.
30133025
30143026 Note: These functions may, in the future,
0 commit comments