Re: Parent Combinator / Parent pseudo-class

In fact, it's not very complicated to find the matching elements.

<<
    before-selector selector:with-child(child-selector) after-selector {
        property: value;
    }
>>

<<
    var matchingEls = concat(
        from el in document.querySelectorAll('before-selector selector')
                where el.querySelector('child-selector') isnot null
        select el.querySelectorAll('after-selector')
    );
>>

I don't see where we must apply two time the same selector...

In fact, we only apply three selectors :
- A first selector to match all possibly matched elements
- A second selector that we apply only while no matching element is found.
- A last selector, that's called only if a element matched the second 
selector.

If no element matched the second one, the last one is not executed.

--------------------------------------------------
From: "Alan Gresley" <alan@css-class.com>
Sent: Wednesday, July 23, 2008 5:05 PM
To: "Brad Kemper" <brkemper@comcast.net>
Cc: <w3mail@jixor.com>; <www-style@w3.org>
Subject: Re: Parent Combinator / Parent pseudo-class

>
> Brad Kemper wrote:
> [...]
>>> A parent combinator pseudo-class or parent pseudo-class requires a CSS 
>>> parser to walk the chain.
>>
>> Only of immediate children, not of all descendants of a particular 
>> has-child selector. Anyone using it more than sparingly should expect 
>> some performance degradation.
>
>
> But what Stephen is`suggesting is firstly to walk the chain backwards to 
> the parent element and then secondly match each particular parent child 
> combinator. If my understanding is correct, that is a double performances 
> hit.
>
>
> -- 
> Alan http://css-class.com/
>
> Nearly all men can stand adversity, but if you want to test a man's 
> character, give him power - Abraham Lincoln
> 

Received on Wednesday, 23 July 2008 15:29:19 UTC