Repository navigation
Closed
Labels
from: GoogleProposed, edited, or co-edited by Google.position: supporttopic: cssSpec relates to CSS (Cascading Style Sheets)topic: web apisSpec relates to web APIs (entry points for script)topic: web componentsvenue: WICGProposal is incubated in the Web Incubator Community Group
Description
Request for position on an emerging web specification
Information about the spec
- Spec Title: Exposing custom element states
- Spec URL: https://wicg.github.io/custom-state-pseudo-class/#customstateset
- Issue Tracker (if not the repository's issue tracker): Custom pseudo-classes for host elements via shadow roots (:state) WICG/webcomponents#738
Anything else we need to know
- WebKit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=215911
Somewhat related to #47. This has been shipped in Chrome for some time.
This provides an API to allow custom element authors a way to expose internal state to the DOM for matching operations (including CSS and things like document.querySelector).
This is done via the ElementInternals.prototype.states, which is a set of custom states. A naive example would be
class FancyElement extends HTMLElement {
constructor() {
super();
const internals = this.attachInternals();
this.internals.states.add('--fancy');
}
}
customElements.define('fancy-element', FancyElement);This would mean that a newly-constructed instance of fancy-element would match against :--fancy.
Reacted by Chris Holt, Bruce B. Anderson, Luke Warlow, Benny Powers, Kir Belevich and Cory LaViska
Metadata
Metadata
Labels
from: GoogleProposed, edited, or co-edited by Google.position: supporttopic: cssSpec relates to CSS (Cascading Style Sheets)topic: web apisSpec relates to web APIs (entry points for script)topic: web componentsvenue: WICGProposal is incubated in the Web Incubator Community Group
Type
Projects
- StatusShow more project fieldsDone
Activity
annevk commentedon Oct 7, 2022
In my mind this is a pretty logical extension of custom elements. Might be good to get input from @nt1m and @anttijk on the selector aspects.
annevk commentedon Nov 11, 2022
I looked at whatwg/html#8467 today and one thing that struck is me is that maybe this can reuse
DOMTokenListrather than introduce a new set-like data structure.rniwa commentedon Nov 12, 2022
We don't oppose this feature. There might be minor issues like using
DOMTokenListand perhaps the use of--prefix but the overall idea seems good here.annevk commentedon Nov 14, 2022
Let's formalize that: I suggest we add the "position: support" label 7 days from now.
rniwa commentedon Nov 14, 2022
Perhaps we should review & give whatever feedback we want to give before we add the label?
annevk commentedon Nov 15, 2022
Ah, I did give my feedback on
DOMTokenListalready. If anyone has more substantive feedback on whatwg/html#8467 or wants to review we can certainly wait a bit before adding the label.annevk commentedon Nov 18, 2022
About :state(token)
vs:--token`::state(token)to:--token.::part(token1 token2)to something like::--token1.token2, but apparently::part()implementations shipped and everyone forgot about that discussion?! (The issue is still open, but that's probably an oversight?):--tokenback to:state(token)so Web Components have internal consistency?annevk commentedon Jan 27, 2023
To follow-up here, @rniwa found a further concern: whatwg/html#8467 (comment).
annevk commentedon Sep 25, 2023
Given that @rniwa's concern has been addressed I once again suggest we resolve this as "position: support" one week from now.