Re: Previous-sibling combinator

On Thu, Aug 16, 2012 at 9:54 PM, Greg Houston <gregory.houston@gmail.com> wrote:
> I think the exclamation point was put in the wrong place. It would be
> better to simply reverse a directional selector. Not only is it much
> easier to write but it makes a little more sense where we generally
> think of the exclamation point as meaning "not", like != (not equal).
> Not UL doesn't make binary sense, but !+ (not next) makes a bit more
> sense for previous.
>
> :matches(!UL + P) > LI
> vs.
> P !+ UL > LI
>
> :matches(!UL ~ P) > LI
> vs.
> P !~ UL > LI
>
> :matches(!UL > P) > LI
> vs.
> P !> UL > LI
>
> :matches(!UL P) > LI
> vs.
> P ! UL > LI
>
> Not sure If I am writing this one correctly using nested :matches...
> :matches(!panel > :matches(!header > :matches(!.float-right > .btn))) > footer
> vs.
> .btn !> .float-right !> header !> .panel > footer

You were corrected in another thread, but for posterity I'll re-answer
this here:

The ! doesn't "reverse a combinator", though it can look like that in
some cases.  It just changes which part of the selector is used to
return a value.

Your last example can be more easily written as:

:matches(!.panel > header > .float-right > .btn) > footer

~TJ

Received on Friday, 17 August 2012 16:59:46 UTC