[css-values-5] toggle() should be a pseudo-class akin to :nth-child()
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- PR merge metrics
- PR metrics pending
Description
A few days ago I ran into the problem of styling nested elements and was informed via Twitter that there's already a toggle() function in the draft stage.
However upon a closer look I'm not sure having it as a function is nearly as useful as a psuedo-class in the veins of :nth-child(), such as :nth-descendant().
There are several disadvantage with the toggle() function compared to a hypothetical :nth-descendant() pseudo-class:
- Must toggle on a per-property basis, so in case of multiple properties you must use multiple
toggle()function and manually sync them up, it gets especially convoluted and verbose if you need to repeat the same value multiple times. - Toggling on a per-property basis also mean you can't logically group multiple values belonging to a single "toggle state" together, they must be intermixed with other toggle states making everything difficult to read.
- Forced to manually declare the sequence of values, instead of using the already existing logic we have for
:nth-child()with itseven,oddandAn+Bsyntax. - No way to toggle based on parent element's nesting level, such as
blockquote:nth-descendant(even) .titlebar {background:blue}. To do this withtoggle()function you'd need to toggle a variable in the parent and then use said variable in the child element, adding undue complexity.
The above is why I believe toggle() should not be a function at all, but a pseudo-class instead.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CSS Values and Units Level 5 draft's toggle() notation section linked in the issue, then compare its model with the existing :nth-child() pseudo-class and An+B syntax. Done would require a resolved CSSWG design for whether and how toggle() becomes a pseudo-class, followed by corresponding specification changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100