DEV Community

Discussion on: BEM Modifiers in Pure CSS Nesting

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Ideally, CSS would have a selector that combines [attr~=value] and [attr$=value] where you could write [attr~$=value] to match any element where attr is a space-separated list of keywords and one of them ends with value.

That way one could just check [class~$="--modifier"] in a relatively safe way. At that point, the only problem would be .foo-list__foo--test and .bar-list__bar--test would both match the --test selector, but that's probably a good bit less likely.