Re: [csswg-drafts] CSS Regex Selector

For some complex real cases, it could be useful, I had a case this afternoon, let's try to explain it simply:

I want to select all elements that have ```class="foo-<*>-bar"``` (I have about 6 or 7 same behaviours with small differences), and __elements may have other classes attached to them__, so impossible to use ```class^=``` or ```class$=```, neither ```class|=```.

I had to use: ```[class*="foo-"][class*="-bar"]``` (which allowed me to save about 50 lines of CSS, and probably more when the website will become more complex)

Problems with this targeting:

- if the CSS classes are not perfectly namespaced => kaboom.
- if I want to factorize all commons properties for ```class="foo-<*>-bar"``` and surcharge after with specific cases - __which is a current pattern with CSS__ -  => the specificity of ```[class*="foo-"][class*="-bar"]``` is too big, I have to use ```.foo-one-bar.foo-one-bar``` to override specificy of the double attribute class, a regexp selector would avoid me to do so.

I agree: it is complex, not everyone will need it => but complex cases sometimes needs powerfull solutions.

-- 
GitHub Notification of comment by nico3333fr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1010#issuecomment-297088661 using your GitHub account

Received on Tuesday, 25 April 2017 16:35:13 UTC