[css-selectors] Substring Matching of Individual Class Names
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the linked Selectors Level 4 attribute-substrings and attribute-case sections, then review the proposed class and ID selector syntax and examples. Done would require an agreed syntax and specification treatment; the issue does not name implementation files or tests.
Written by the indexing model from the issue text.
Description
It's currently possible to match substrings of attribute values, including the class attribute.
https://www.w3.org/TR/selectors-4/#attribute-substrings
It would also be useful to have the ability to match substrings of individual class names. Using the existing attribute selector syntax as a reference, this might look something like:
.classname /* A standard class selector */
.[^class] /* Matches any class name that begins with "class" */
.[$name] /* Matches any class name that ends with "name" */
.[*ass] /* Matches any class name that contains the substring "ass" */
Which would be compatible with the Selectors Level 4 case-sensitivity syntax:
.[^classname i]
.[$classname i]
.[*classname i]
Also, it could be modified to support substring matching in ID selectors:
#[^example] #[^example i]
#[$example] #[$example i]
#[*example] #[*example i]
Such a selector would make it practical to use a naming convention whereby a .Module parent shares common styles with a .SubModule child because although this can be achieved by grouping the related classes, it becomes unwieldy as the number of children increases, for example:
.Module, .SubModule, .AnotherModule, .YetAnotherModule {…}
:matches(.Module, .SubModule, .AnotherModule, .YetAnotherModule).variant {…}
Whereas, this could be rewritten in a simpler form using a substring matching class selector, so that there is no need to manage lists of dependants and style sharing is automatic:
.[$Module] {…} /* Equivalent to .Module */
.[$Module].variant {…} /* Equivalent to .Module.variant */
.SubModule {…} /* Inherits styles from .Module */
.SubModule.variant {…} /* Inherits styles from .Module.variant */
.ModuleUnrelated {…} /* Not matched as name begins not ends with "Module" */
The effect is static inheritance without the use of a preprocessor e.g. @extend in Sass and Stylus.
- Dominant language
- Bikeshed
- Stars
- 4.9k
- Forks
- 816
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 24
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.
More from w3c/csswg-drafts
-
Agenda+ css-sizing-4 css-values-5
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
w3c/csswg-drafts#14502 · 1 reaction ·
-
css-values-5 editorial Needs Edits
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
w3c/csswg-drafts#14498 · 2 comments ·
-
css-overflow-4 topic: line-clamp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
w3c/csswg-drafts#14485 · 1 comment ·
-
Administrative Tracker css-values-4
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
w3c/csswg-drafts#14482 · 4 comments · 1 reaction ·
-
css-values-5 Needs Edits
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
w3c/csswg-drafts#14466 ·
All issues in w3c/csswg-drafts
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
tvOS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bvaughn/react-resizable-panels#751 · 1 comment ·
-
www.wiwo.de OpenN: AdGuard Browser Extension P3: Medium T: Annoyance
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
AdguardTeam/AdguardFilters#242026 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 92/100