Re: Selectors 4 and Variables

I believe you are thinking of the multiple discussions where people (you,
me, Hixie, others?) have made this case to no avail.  To recap:  I believe
fantasi's concern was that combinators are problematic without extra syntax
like:

doc:has($ > .foo)

Unless you go jquery route (which I like) and scope it so that the lhs of
the combinator can be left off (because it is pretty unambiguous).

As Hixie and I have both pointed out, has actually has several benefits:

1. Can occur multiple times as in
div:has(.foo)+div:has(.bar)

2.  Ask a designer to read the two versions... Has is intuitive.

3.  It is essentially asking to codify something already popular and
proven... How often do you get a win like that?
On Sep 30, 2011 8:05 PM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:
> 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:22:44 UTC