Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

::part(): Missing information #23471

Open
estelle opened this issue Jan 8, 2023 · 2 comments
Open

::part(): Missing information #23471

estelle opened this issue Jan 8, 2023 · 2 comments
Labels
Content:CSS Cascading Style Sheets docs

Comments

@estelle
Copy link
Member

estelle commented Jan 8, 2023

MDN URL

https://developer.mozilla.org/en-US/docs/Web/CSS/::part

What specific section or headline is this issue about?

all of it

What information was incorrect, unhelpful, or incomplete?

there are tons of limits on using ::part(), not of which are described.

What did you expect to see?

Selecting a Shadow Element: the ::part() pseudo-element

The ::part() pseudo-element allows you to select elements that have been exposed via a part attribute. The syntax is:

::part() = ::part( <ident>+ )

The ::part() pseudo-element only matches anything when the originating element is a shadow host. If the originating element’s shadow root’s part element map contains all of the specified <ident>s, ::part() matches the element or elements keyed to that <ident>. Otherwise, it matches nothing.
For example, if you have a custom button that contains a "label" element that is exposed for styling (via part="label"), you can select it with #the-button::part(label).
Part names act similarly to classes: multiple elements can have the same part name, and a single element can have multiple part names.

A tabstrip control might have multiple elements with part="tab", all of which are selected by ::part(tab).

If a single tab is active at a time, it can be specially indicated with part="tab active" and then selected by ::part(tab active) (or ::part(active tab), as order doesn’t matter).

The ::part() pseudo-element can take additional pseudo-classes after it, such as x-button::part(label):hover, but never matches the structural pseudo-classes or any other pseudo-classes that match based on tree information rather than local element information.

The ::part() pseudo-element can also take additional pseudo-elements after it, such as x-button::part(label)::before, but never match additional ::part()s.
For example, x-panel::part(confirm-button)::part(label) never matches anything. This is because doing so would expose more structural information than is intended.

If the <x-panel>’s internal confirm button had used something like part="label => confirm-label" to forward the button’s internal parts up into the panel’s own part element map, then a selector like x-panel::part(confirm-label) would select just the one button’s label, ignoring any other labels.

Do you have any supporting links, references, or citations?

https://w3c.github.io/csswg-drafts/css-shadow-parts/#part

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@estelle estelle changed the title Missing information Jan 8, 2023
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jan 8, 2023
@sideshowbarker sideshowbarker removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 9, 2023
@BobH-Official
Copy link

A related issue for ::part(). #31932

@hamishwillee
Copy link
Collaborator

@estelle Were you planning on doing this work. I could take it on as part of #31971 but it sounds like you have a grip on what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs
4 participants