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

Custom states & default ARIA for slotted built-ins #10723

Open
LeaVerou opened this issue Oct 25, 2024 · 1 comment
Open

Custom states & default ARIA for slotted built-ins #10723

LeaVerou opened this issue Oct 25, 2024 · 1 comment
Labels
accessibility Affects accessibility addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Comments

@LeaVerou
Copy link

What problem are you trying to solve?

Web components often need to slot native elements, for example:

  • A <button-group> component slotting <button> elements
  • An <x-accordion> or <sidebar-panel> component slotting <details>
  • Carousels, tab panels, etc. often need to slot existing block elements
  • A <check-list> slotting a <li> (see Allow any element to be the child of a custom element (parser weirdness permitting) #10722)
  • A <checkbox-group> slotting a <label>
  • A <x-dropdown> slotting an <option>
  • A <tab-group> or carousel component using arbitrary block elements as tab panels
  • etc

It is common to need to expose state about these slotted children to CSS (:state()), and in some cases to specify ARIA roles without spawning attributes (which is seen as an antipattern). However, given that ElementInternals is only available to custom elements, there is no states, and no way to set default ARIA, so this cannot be done.

What solutions exist today?

Components invent their own children instead of using built-ins, simply to set an ARIA attribute or to use custom states, then they have to mirror their API (and lose any heuristics about built-in elements that exist in lots of tooling or even the UA itself).

How would you solve it?

A way to attach a reduced ElementInternals to any element (just like a shadow tree can be attached to built-ins too)?

Anything else?

No response

@LeaVerou LeaVerou added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Oct 25, 2024
@LeaVerou LeaVerou changed the title A reduced ElementInternals for built-ins? Custom states & default ARIA for slotted built-ins Oct 25, 2024
@keithamus keithamus added accessibility Affects accessibility topic: custom elements Relates to custom elements (as defined in DOM and HTML) labels Oct 25, 2024
@whatwg whatwg deleted a comment from aswin-devil Oct 29, 2024
@annevk
Copy link
Member

annevk commented Nov 5, 2024

I think this would end up being weird as the ElementInternals would end up having to be public API, which attributes are too. So there's not really a difference except in invocation syntax.

If you want custom API using custom elements is really the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Affects accessibility addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

No branches or pull requests

3 participants