Re: Selectors 4 and Variables

On Thu, Sep 29, 2011 at 11:35 PM, Daniel Glazman
<daniel.glazman@disruptive-innovations.com> wrote:
> Hi there,
>
> Both Selectors 4 and Variables now use the $ to represent something.
> I think this is wrong and will lead to CSS maintainance issues
> for web authors since a textual search for $p inside a style sheet will
> retrieve not only the definitions/calls to variable p but also the
> selectors having for subject a p. If this case will be probably be rare
> - but real - in the html world, it could be bigger in the xml one.
> I don't want to see that happen.
>
> I really have the gut feeling we should use different char descriptors
> here. Long, really long ago, I proposed to use !. I still think this is
> the best option, something very visual meaning an emphasis on the
> corresponding simple selector.

I thought it was generally agreed long ago that the best approach was
to use :has() rather than a marker in the selector.  It's more general
and allows more types of things to be expressed.

Basically, the subject indicator is exactly equivalent to a :has()
pseudo limited to the end of the selector:

foo $bar baz {...} == foo bar:has(baz) {...}

However, :has() can be placed anywhere in the selector, and so allows
more powerful selections:

label:has(:checked) + section > p {...}

This also has the nice benefit of not using up the $ (or any other
glyph) inside of selectors.

~TJ

Received on Saturday, 1 October 2011 00:04:24 UTC