-
Notifications
You must be signed in to change notification settings - Fork 715
[css-shadow-parts] Expose parts programmatically #3228
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
Comments
That does seem useful indeed. |
Yeah, this seems useful to expose; otherwise, the only place such information is exposed is in the (hopefully existent!) library docs. It feels like something that DevTools would want to expose too; DevTools has magic powers and can get into closed shadow roots, but other tools offering similar behavior wont' have those powers and would want this information. |
With Are there other useful things that external dev tools cannot do with closed custom elements or shadow roots that built-in dev tools can? By useful I guess I mean things like API discovery, not things like digging around in implementation details. |
That's a reasonable concern; marking it as a function rather than an attribute is probably appropriate, then. This recursion is no more expensive than many other recursive operations, so we don't need to do anything more special than that. But having it recurse does violate the usual expectation of attributes=cheap. |
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:
The goal would be to allow something like:
The text was updated successfully, but these errors were encountered: