You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When styling web components with multiple named slots, the :first-child / :last-child / :nth-child pseudo-classes, when used inside the :slotted() pseudo-element, represent an element's relationship to it's light DOM siblings.
We expect :slotted(*:first-child) to apply only to #first.
We expect :slotted(*:last-child) to apply only to #last.
We expect :slotted(*:nth-child(2)) to apply only to #nth-2.
Given named slots, many authors expect these pseudo-classes to represent the element's relationship to it's fellow slotted siblings as such:
:slotted(*:first-child) expected to apply to #first, #nth-2, and #last.
:slotted(*:last-child) expected to apply to #nth-3, #nth-4, #last.
:slotted(*:nth-child(2)) expected to apply to #nth-3, #nth-4, #last.
[name="two"]:slotted(*:first-child) expected to apply only to #nth-2.
[name="one"]:slotted(*:last-child) expected to apply only to #nth-3.
Rather than muddy the existing behavior of :first-child etc., I propose we add :first-assigned / :last-assigned / :nth-assigned() which will represent a slotted element's relationship to it's sibling assigned nodes. ++ @Westbrook for the naming proposal!
The text was updated successfully, but these errors were encountered:
When styling web components with multiple named slots, the
:first-child
/:last-child
/:nth-child
pseudo-classes, when used inside the:slotted()
pseudo-element, represent an element's relationship to it's light DOM siblings.CodePen: https://codepen.io/castastrophe/pen/yLXpagw
Given the following markup:
:slotted(*:first-child)
to apply only to#first
.:slotted(*:last-child)
to apply only to#last
.:slotted(*:nth-child(2))
to apply only to#nth-2
.Given named slots, many authors expect these pseudo-classes to represent the element's relationship to it's fellow slotted siblings as such:
:slotted(*:first-child)
expected to apply to#first
,#nth-2
, and#last
.:slotted(*:last-child)
expected to apply to#nth-3
,#nth-4
,#last
.:slotted(*:nth-child(2))
expected to apply to#nth-3
,#nth-4
,#last
.[name="two"]:slotted(*:first-child)
expected to apply only to#nth-2
.[name="one"]:slotted(*:last-child)
expected to apply only to#nth-3
.Rather than muddy the existing behavior of
:first-child
etc., I propose we add:first-assigned
/:last-assigned
/:nth-assigned()
which will represent a slotted element's relationship to it's sibling assigned nodes. ++ @Westbrook for the naming proposal!The text was updated successfully, but these errors were encountered: