WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
233 stars 16 forks source link

Pseudo States Style Introspection (ala :hover) #107

Open thysultan opened 1 year ago

thysultan commented 1 year ago

Introduction

The getComputedStyle API currently only allows a user to get the current computed state, leaving much-to desired should the author want to probe for a specific state such the :hover state or :focus-within.

Use Cases (Recommended)

At present you need special privilege(as an extensions or debug session) to get the pseudo states of an element i.e the CSS.forcepseudostate API currently present in Chrome that dev tools and other debug applications use to toggle programmatically between an elements pseudo states.

Goals (Optional)

Non-goals (Optional)

Proposed Solution

Examples (Recommended)

Chrome Developer Tools has the ability to force :hover, :focus states of an element to preview the styles that are applied when those states are active.

Screenshot 2023-07-06 at 10 56 19 PM

Alternate Approaches (Optional)

Currently there's no way to get the hover state without establishing control of both sides, that is both the provider(author) and consumers(the tool trying to introspect) i.e in using a div.hover, div:hover class in addition to a :hover state and managing the mouseenter state to trigger the class.

Privacy & Security Considerations

The :visited state, but those issue have been tackled in previous introspections of its use and issues. The same mitigations would apply in this case.

Let’s Discuss (Optional)

Should allowance be made for custom states forcePseudoState(":walking") that can be toggled.