Skip to content

Support for the new :state() syntax #126

@KonnorRogers

Description

@KonnorRogers

With the deprecation of the :--state syntax, I imagine the restrictions around requiring the -- prefix should be removed.

https://groups.google.com/a/chromium.org/g/blink-dev/c/GDmNaxAuCY4/m/WOQD5uRTAQAJ

https://html.spec.whatwg.org/multipage/custom-elements.html#exposing-custom-element-states

It has not been implemented in Chrome yet, but it has been implemented in Safari TP and I believe is being worked on for Firefox.

if (!/^--/.test(state) || typeof state !== 'string') {
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${state} must start with '--'.`);
}

https://codepen.io/dannymoerkerke/pen/KKEyarg

^ Example supporting both syntaxes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions