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

Allow any element to be the child of a custom element (parser weirdness permitting) #10722

Open
LeaVerou opened this issue Oct 25, 2024 · 3 comments
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. document conformance topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Comments

@LeaVerou
Copy link

What problem are you trying to solve?

Certain elements, such as <li> or <option> are only permitted within certain element types. Should this perhaps be expanded to custom elements? Many use cases where a custom element may reasonably want to slot these.

What solutions exist today?

Currently they need to invent their own elements (e.g. <sl-option>) that provide no functionality, and just mirror the API of these.

How would you solve it?

If there is no parser weirdness, allow any element to have a custom element as a parent. @annevk thought that sounds reasonable, with that caveat.

Anything else?

No need to do it all at once, it could be done one element at a time, starting from <li> and <option>, which are the ones I most frequently needed to slot personally.

@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 Allow any element to be the child of a custom element, parser weirdness allowing Allow any element to be the child of a custom element (parser weirdness permitting) Oct 25, 2024
@keithamus keithamus added the topic: custom elements Relates to custom elements (as defined in DOM and HTML) label Oct 25, 2024
@domenic
Copy link
Member

domenic commented Oct 28, 2024

This is just a proposed change to conformance requirements, as I understand it, so I'll re-tag a bit.

One possible consideration here is accessibility. E.g., we may want to require that <li> elements are children of custom elements whose default ARIA role semantics (as set by elementInternals.role) are list.

@domenic domenic added document conformance a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. and removed addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Oct 28, 2024
@stevefaulkner
Copy link
Contributor

stevefaulkner commented Oct 30, 2024

allow any element to have a custom element as a parent.

Sounds OK, but the custom parent element would need to have a role that allows role="listitem" or role="option" as children no? Unless the <option> or <li> default roles are overwritten by an explicit role.

from ARIA 1.3 editors draft: https://w3c.github.io/aria/

Authors MUST ensure elements whose role is listitem are accessibility children of an element whose role is list.

Authors MUST ensure elements with role option are accessibility children of an element with role listbox or of an element with role group that is the accessibility child of an element with role listbox. Options not associated with a listbox might not be correctly mapped to an accessibility API.

@LeaVerou
Copy link
Author

LeaVerou commented Nov 1, 2024

I think framing it around roles, rather than element types makes a lot of sense! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y-tracker Group bringing to attention of a11y, or tracked by the a11y Group but not needing response. document conformance topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

No branches or pull requests

4 participants