Re: proposal for a new css combinator

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.

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.

-- 
Øyvind Stenhaug
Core Norway, Opera Software ASA

Received on Thursday, 14 January 2010 15:25:17 UTC