<my-element>MyElement</my-element>
my-element:state(clicked) {
color: red;
}
class MyElement extends HTMLElement {
#internals;
constructor() {
super();
this.#internals = this.attachInternals();
this.addEventListener("click", this.#onClick.bind(this));
}
#onClick() {
this.#internals.states.add("clicked");
}
}
customElements.define("my-element", MyElement);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.