Skip to content

Commit 5143058

Browse files
authored
[css-values-5] Pseudo element and tree-scope for sibling functions #9573 (#11830)
Per resolution in #9573, element-backed pseudo elements that refer to an element in an inner scope should not expose their tree order to tree counting functions. Spec text now says they instead resolve to 0, loosely based on the minutes[1]. Additionally, re-word the text for how tree counting functions resolve against pseudo elements. This is not backed by a resolution, but backed by the discussions in the meeting minutes[1]. [1] #9573 (comment)
1 parent fc18e62 commit 5143058

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

css-values-5/Overview.bs

+40-3
Original file line numberDiff line numberDiff line change
@@ -2524,9 +2524,46 @@ Tree Counting Functions: the ''sibling-count()'' and ''sibling-index()'' notatio
25242524
Note: The ''counter()'' function can provide similar abilities as ''sibling-index()'',
25252525
but returns a <<string>> rather than an <<integer>>.
25262526

2527-
When used on a [=pseudo-element=],
2528-
these both resolve as if specified
2529-
on its [=ultimate originating element=].
2527+
When used on an [=element-backed pseudo-element=] which is also a real element,
2528+
the tree counting functions resolve for that real element. For other pseudo
2529+
elements, they resolve as if they were resolved against the
2530+
originating element. It follows that for nested pseudo elements the resolution
2531+
will recursively walk the originating elements until a real element is found.
2532+
2533+
A tree counting function is a [=tree-scoped reference=] where it references
2534+
an implicit [=tree-scoped name=] for the element it resolves against. This is
2535+
done to not leak tree information to an outer [=tree=]. A tree counting
2536+
function that is scoped to an outer [=tree=] relative to the element it
2537+
resolves against, will alway resolve to 0.
2538+
2539+
<div class=example>
2540+
Examples of how ''sibling-index()'' resolves for pseudo elements, and when the
2541+
rule and the element come from different [=trees=]:
2542+
2543+
<pre class=lang-css>
2544+
#target::before {
2545+
/* Based on the sibling-index() of #target */
2546+
width: calc(sibling-index() * 10px);
2547+
}
2548+
#target::before::marker {
2549+
/* Based on the sibling-index() of #target */
2550+
width: calc(sibling-index() * 10px);
2551+
}
2552+
::slotted(*)::before {
2553+
/* Based on the sibling-index() of the slotted element - outer tree */
2554+
width: calc(sibling-index() * 10px);
2555+
}
2556+
::part(my-part) {
2557+
/* 0px - inner tree */
2558+
width: calc(sibling-index() * 10px);
2559+
}
2560+
:host {
2561+
/* Based on the hosts sibling-index() - outer tree */
2562+
width: calc(sibling-index() * 10px);
2563+
}
2564+
</pre>
2565+
2566+
</div>
25302567

25312568
Note: Like the rest of CSS (other than [=selectors=]),
25322569
''sibling-count()'' and ''sibling-index()''

0 commit comments

Comments
 (0)