~alcinnz/haskell-stylist

ref: e8442cdfb21a746bfb3b5503c637a6fe8895bead haskell-stylist/ISSUES/psuedoclass-lowering.md -rw-r--r-- 2.5 KiB
e8442cdf — Adrian Cochrane ISSUES: Plan psuedoclass lowering. 4 years ago
                                                                                
9503b788 Adrian Cochrane
e8442cdf Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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.