Re: [css3-selectors] :parent selector

I don't think it's a good idea to create two versions of CSS selectors? The
power of the Selectors API is imho that it has the same syntax as
CSS-selectors, and isn't it confusing to have two slightly different
versions of CSS-selectors?

I suggest the following:
- During the parsing of an element, the element is checked against all
css-rules. At this stage (pointers to) the applying rules are saved, as a
kind of cache or optimization.
- When parsing a child element, and a matching parent selector is found, a
flag is set on the parent element and the rules with the parent selector are
added to the 'cache' we created in step 1.
- When all other childs are parsed, we only need to check the flag, to see
if there are parent selectors found, and only then the cached rules needs to
be re-evaluated. Because the cache contains only (pointers to) rules that
apply, this can be done very fast. After this we can remove the 'cache'.

I think it's very efficient: we need to check all selectors only once for
each element, and incremental rendering is still possible. If a parent
selector is found, we use a sort of cache, so we don't have to match all
rules two times.

Regards,

Jan de Mooij


On 10/6/06, Richard York < richy@smilingsouls.net> wrote:
>
>
>
>
>
> On 9/26/06 2:16 AM, "David Woolley" <david@djwhome.demon.co.uk> wrote:
>
> >> CSS, what about using a parent selector in something like a future
> >> getElementsBySelector() method in script?
> >
> > Wouldn't get elements by XPath expression be more appropriate, and
> already
> > implemented on many platforms.
>
> Sorry for the belated reply.  Well, Anne van Kesteren is already well
> underway in specifying a Selectors API [1], though the methods in his WD
> are
> called matchAll() and matchSingle(), rather than getElementsBySelector().
>
> Anyway, while a parent/ancestor selector may not be technically feasible
> for
> incremental rendering CSS, it would be absolutely feasible, and expected,
> in
> a Selectors API, since there are no incremental rendering issues there,
> and
> at least setting aside the syntax for that purpose, I think, is a good
> thing.
>
> [1] http://www.w3.org/TR/2006/WD-selectors-api-20060926/
>
> Regards,
> Richard York
>
>
>
>

Received on Sunday, 8 October 2006 02:44:47 UTC