Re: [css4-selectors] Focused descendant pseudo class

On Thu, Jan 26, 2012 at 3:47 PM, Brice PARENT <brice@websailors.fr> wrote:
> Even if we're talking about it, i was still taking the "!" for something
> it shouldn't be...
>
> So, what's does the "!" adds? Shouldn't we have the simple
> "form:matches(> input:focus) input[submit]{...}"?
> We have "form input[submit]" which declares css properties, but only if
> "form" (the element which has the :matches) also validates "form >
> input:focus". It just requires to put the :matches on a common node,
> which could be "body" for html, in the worst case.
> Do anyone have a use case where it is needed to have the "!" later in
> the parentheses?

Yes.  Say you wanted to match an element based on the presence of two
ancestors, but the two can occur in any order in the ancestor chain
(they may be nestable widgets, for example).  You can do this with:

"ancestor1 elem:matches(ancestor2 !)"

This can be expressed without :matches, but it requires duplication:
"ancestor1 ancestor2 elem, ancestor2 ancestor1 elem".

~TJ

Received on Thursday, 26 January 2012 23:54:06 UTC