W3C home > Mailing lists > Public > www-style@w3.org > February 2015

Re: element existence selector

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Fri, 27 Feb 2015 13:07:39 -0500
Message-ID: <54F0B26B.3030702@mit.edu>
To: www-style@w3.org
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"...

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

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:51 UTC