Re: Parent Combinator / Parent pseudo-class

Francois Remy wrote:
> But it's not possible to know when an element changes in JScript...

Not strictly true, as long as you trust mousein/out and mutation events. 
  But that's not important.

> imagine this case :
...
> and this rule :
>  
>     div#base div.el1:with-child(a:hover b) span:hover { color: green; }

> The rule need to be reevaluated each time :
> -    (1) The elements matched by "div" change (any DIV can get or loose 
> id="base")

How do you (or rather the implementation) know you only need to worry 
about changes to <div> elements?

> -    (2) The elements matched by "div#base div" change (any DIV of 
> div#base can get or loose class="el1")
> -    (3) The elements matched by "div#base div.el1 span" change (any 
> SPAN can get or loose :hover)

You missed several cases along the lines of:

(4) Any subtree that might contain a <b> element is inserted anywhere in 
the document.
(5) Any subtree that might contain a <b> element is removed anywhere in 
the document.

These are what make life hard with this sort of selector.

> The with-child rule need to be reevaluated each time :
> -    (4) The first element matched by "div#base div.el1 a:hover b" change
> -    (5) The first ancestror of the "b" that matches "a:hover" change

You missed some cases.  See above.

> At loading time :

Again, the worry is less loading time than dynamic DOM updates.  But 
even for loading time...

> For each div1 matched by document.getElementsByTagName("div")

This happens every time content is incrementally added to the document, 
right?  Since this operation is O(n), that makes pageload O(n*n) at best 
with your algorithm.

-Boris

Received on Thursday, 24 July 2008 17:26:27 UTC