:predefined
pseudo-class for built-ins (i.e. not custom elements)
#11001
Labels
HTML
Requires coordination with HTML people
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.)
The text was updated successfully, but these errors were encountered: