W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Proposal for limited :matches pseudoclass

From: Simetrical <simetrical@gmail.com>
Date: Thu, 31 Jul 2008 18:15:14 -0400
Message-ID: <7c2a12e20807311515k298659a3ic4890d8bf4e20143@mail.gmail.com>
To: "Francois Remy" <fremycompany_pub@yahoo.fr>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, "www-style list" <www-style@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT