Re: Proposal for limited :matches pseudoclass

On Thu, Jul 31, 2008 at 6:08 PM, Francois Remy
<fremycompany_pub@yahoo.fr> wrote:
> Why ?
> foo:matches(bar)
> is not more complex that "foo bar". Why should we change the style of the
> :root element ?

You would have to if the :root element was "foo"

> The only element that change change of style is "foo", and ONLY IF we add a
> bar element in it
> and that there was NO ONE in it before. Same if we delete a BAR in a foo
> that was the only BAR
> child of the FOO. But never we must change the style of :root.

You do, if you have *:matches( bar) or :root:matches( bar) or anything
like that.  You're correct that it would only have to be checked once
if any number of spans were added, but it would have to be checked
again if a span were repeatedly added or removed, say.

> As sample :
>
>   <span id="s1">
>   <div id="d1"><span id="s2"></span></div>
>   <div id="d2"></div>
>
> div:matches(span) only match the "d1" DIV.

But *:matches(span) would be allowed equally.  Or you could have the
very common setup of a global wrapper div, like

<body><div id="top">
...lots of page content...
<span id="s1"></span> <-- When this is added to the DOM you must
re-evaluate every element contained within <body> (except <body>
itself).
...lots more page content...
</div></body>

Of course in special cases this might be fast.  But there will be
*some* cases where it's very, very slow.  Best-case complexity is fine
here.  Worst-case complexity is the problem.  Worst-case complexity of
"a + b", on the other hand, or "a b", is quite good.

Received on Thursday, 31 July 2008 22:15:49 UTC