[css-shadow-parts] Expose parts programmatically
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
It would be helpful for components with parts to expose those parts in some way that's programmatically inspectable.
For components with an open shadow root, someone could query inside the shadow for elements that have a part attribute, but this is not possible for components with closed shadow roots. To avoid leaking shadow elements, the proposed mechanism would return an array of string part names, not elements.
This would be akin to property reflection, and good for things like design/debugging/testing tools. E.g., it'd be nice if a tool could ask a DOM element what parts it has so that the tool can show the user a list of the parts available for styling.
Using the spec's example:
<template id="c-e-template">
<span part="textspan">This text will be red</span>
</template>
The goal would be to allow something like:
const e = document.createElement('custom-element');
e.parts; // Returns the array ['textspan']
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is identified in the issue. Start by reviewing the CSS Shadow Parts specification and the open discussion, then define the programmatic parts API and its behavior for closed shadow roots. Done means the proposal is specified clearly enough for tools to retrieve an element's part names without exposing shadow elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100