Re: proposal for a new css combinator

On Thu, Jan 14, 2010 at 9:24 AM, Øyvind Stenhaug <oyvinds@opera.com> wrote:
> On Thu, 14 Jan 2010 14:51:16 +0100, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>
>> On Thu, Jan 14, 2010 at 6:41 AM, Alan Gresley <alan@css-class.com> wrote:
>
> (...)
>
>>> .focusBlock header:first-descendant {
>>> // style rules //
>>> }
>>>
>>>
>>> In theory you could also have last-descendant.
>>>
>>>
>>> .focusBlock header:last-descendant {
>>> // style rules //
>>> }
>>
>> :last-descendant would actually be marginally easier to implement, if
>> I'm thinking correctly, and plenty useful on its own (for many of the
>> same reasons that jQuery's closest() method is so useful).
>
> I'm not very familiar with typical implementation details, but I would've
> thought it were the other way around. When checking for a first descendant
> one would just need to walk up the tree, aborting if a header is found and
> giving a match if a .focusBlock is found. When checking for a last
> descendant it seems one would need to check the entire sub-tree of the
> header.

Oh, you're right.  You would have to verify the descendants of header
as well.  If you already know you're on a leaf, then it's really easy,
though.

> Anyway, syntax-wise a combinator seems more natural than a pseudo-class. I
> can't think of any other pseudo-class where determining a match depends on
> what simple selectors there are earlier in the sequence.

You're right; I knew there was something niggling in the back of my
brain about it.  Combinators are indeed the way we indicate
relationships between different parts of the selector; pseudoclasses
and the like can only tell us special things about the document
itself, not the selector.  It would be best to maintain that
distinction.

~TJ

Received on Thursday, 14 January 2010 15:36:34 UTC