Re: Proposal for limited :matches pseudoclass

On Thu, Jul 31, 2008 at 6:21 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> I'm not sure I get you here.  Given "foo + bar", a DOM mutation could
> certainly recompute the style of descendants.  It would simply be the
> descendants of bar that possibly get recomputed styles, whereas in
> foo:matches(+ bar) it's foo's descendants that may need recomputation.  Is
> there something I'm overlooking here that allows you to avoid recomputing
> styles upon a DOM mutation if you use the "foo + bar" rule?

It depends on the mutation, I guess.  If you were to insert a new
"bar" after foo, which is a very common case (right?), it would have
no descendants that need to be recomputed.  If you were to delete a
"bar" after foo, again, no recomputation for descendants.  Only if you
change an element after foo that already has descendants to match
"bar" will you need to recompute "bar"'s descendants.  But in all
three cases you would have to recompute the descendants of "foo".

Of course, you could also change the element before bar to match foo.
In this case I guess it's reversed: you'll then have to recompute all
of bar's descendants for "foo + bar", but for "foo:matches(+ bar)"
you'd only have to recompute foo and its descendants, which is no
extra cost.  I guess that's what you're saying.

I don't really know.  Maybe I don't understand after all.  Or maybe
this isn't a problem at all for sibling selectors, only child or
descendant selectors.

Received on Thursday, 31 July 2008 22:52:53 UTC