W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Parent Combinator / Parent pseudo-class

From: Francois Remy <fremycompany_pub@yahoo.fr>
Date: Wed, 23 Jul 2008 17:28:38 +0200
Message-ID: <115776A0F5524F59A86C0469B710AB27@FremyCompany1>
To: "Alan Gresley" <alan@css-class.com>, "Brad Kemper" <brkemper@comcast.net>
Cc: <w3mail@jixor.com>, <www-style@w3.org>

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 

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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC