~alcinnz/haskell-stylist

ref: 3df8d43cf9f4555f3b4bc55703c14708eb036cdd haskell-stylist/ISSUES/psuedoclass-lowering.md -rw-r--r-- 2.5 KiB
3df8d43c — Adrian Cochrane Implement psuedoclass rewrite rules. 4 years ago

#Provide API to lower non-functional psuedoclasses

It may be simpler, though less featureful[1], to implement interactive psuedoclasses as if they were psuedoelements. That way when the style tree has been interacted, we can retrieve the altered styles rather than reapply the full stylesheet.

Many other psuedoclasses are equivalent to other selectors, especially if the caller doesn't implement certain interactions.

As such there should be a StyleSheet decorator that can be configure to perform these tasks.

#Notes

  1. Rewriting psuedoclasses to psuedoelements would not allow a browser to support selectors like ":hover li" that are popularly used to create offline-interactive pages without JavaScript.

However it is probably wise to discourage such patterns, as they do not communicate necessary state to accessibility tools.

#Lowering Rules

:active -> interactive :any-link, :link -> :where([href], [src]) :blank -> :where(input[value=""]) :checked -> [checked] :default -> UNSUPPORTED (forms) :defined -> UNSUPPORTED (custom elements) :dir(_) -> :where([dir=_], [dir=_] *) :disabled -> [disabled] :empty -> would need to be handled by XML Conduit Stylist. :enabled -> :not([disabled]) :first-child -> :nth-child(1) :first-of-type -> :nth-of-type(1) :fullscreen -> Handled elsewhere. :focus, :focus-visible -> interactive :focus-within -> interactive :host -> UNSUPPORTED (custom elements) :host() -> UNSUPPORTED (custom elements) :host-context() -> UNSUPPORTED (custom elements) :hover -> interactive :indeterminate -> [indeterminate] :in-range -> UNSUPPORTED (forms) :invalid -> UNSUPPORTED (forms) :lang(_) -> :where([lang|=_], [lang|=_] *) :last-child -> :nth-last-child(1), PROBABLY UNSUPPORTED :last-of-type -> :nth-last-of-type(1), PROBABLY UNSUPPORTED :only-child -> :nth-child(1):nth-last-child(1), PROBABLY UNSUPPORTED :only-of-type -> :nth-of-type(1):nth-last-of-type(1), PROBABLY UNSUPPORTED :optional -> :not([required]) :out-of-range -> UNSUPPORTED (forms) :placeholder-shown -> :where(:not([value]), [value=""]) :readonly -> [readonly] :read-write -> :not([readonly]) :required -> [required] :root, :scope -> html, or applied by XML Conduit stylist for more leniency. :state() -> UNSUPPORTED (custom elements), may want an alternative. :target -> #_, selected ID sourced from outside data. :valid -> UNSUPPORTED (forms) :visited -> requires special handling, with outside data.