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

:predefined pseudo-class for built-ins (i.e. not custom elements) #11001

Open
LeaVerou opened this issue Oct 4, 2024 · 0 comments
Open

:predefined pseudo-class for built-ins (i.e. not custom elements) #11001

LeaVerou opened this issue Oct 4, 2024 · 0 comments
Labels
HTML Requires coordination with HTML people

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Oct 4, 2024

It is currently impossible to match custom elements generically. :not(:defined) matches custom elements that have not yet been defined, but since :defined also matches built-ins, there is no way to target all custom elements.

Admittedly the use cases for this are niche (it came up in a Twitter discussion with a framework author who said they use a different code path when the template contains custom elements), but also it’s a pretty simple addition, so why not.

We could introduce a :predefined pseudo-class to match native elements, authors can simply use :not(:predefined) to match custom elements. Or we could introduce a pseudo-class to directly match custom elements, though I have no idea what to call it 🙃

(Ideally we should eventually introduce more granular selectors to target element by tag prefix and/or suffix but this is a nice quick fix that can be implemented pretty easily, and is useful in its own right.)

@LeaVerou LeaVerou added the HTML Requires coordination with HTML people label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML Requires coordination with HTML people
Projects
None yet
Development

No branches or pull requests

1 participant