Re: element existence selector

On 2/27/15 12:04 PM, Henrik Andersson wrote:
> You mention invalidation being difficult, do you want to say that
> browsers cache subtrees independently? To me it seems like that could be
> solved with a pointer. Specifically, splitting the selector into the
> subparts and letting each subpart let the other part know that it needs
> to be reevaluated.

You have this somewhat backwards.

Browsers don't "evaluate" selectors, for styling purposes.  Browsers 
take an element and see whether it matches all the selectors around.

That means that when a mutation happens, you have to find the set of all 
elements (call this the "dirty element" set) whose style might have 
changed and hence need to be recomputed.  There are fast ways to 
determine this set (e.g. restyle the whole document), but they lead to 
slow style recomputation.  So browsers do various things to cut down on 
the size of the "dirty element" set based on the actual selectors that 
are present and the DOM mutation that occurred.

 From that point of view, allowing selectors whose mere presence in a 
stylesheet means that the "dirty element" set for many DOM mutations 
must be the all the elements in the document seems like it will just 
lead to people being upset that "the DOM is slow"...

-Boris

Received on Friday, 27 February 2015 18:08:12 UTC