W3C home > Mailing lists > Public > www-style@w3.org > September 2013

[selectors4] Use pesudo-class instead for selecting parent elems

From: Xidorn Quan <quanxunzhen@gmail.com>
Date: Sat, 31 Aug 2013 15:10:33 +0800
Message-ID: <CAMdq69-s0zNRc0HTFEZDbmWnavi9XLcsbJYVWjn1LbF=LoNMTQ@mail.gmail.com>
To: www-style@w3.org
Hi all,

I am new here. I have a suggestion for selecting parent elements.

In the current draft, a new mechanism is introduced to change the
subjects of a complex selector, which is prepending (or appending)
exclamation mark, so that an element can be selected according to its
descendents.

But IMHO, it is not a flexible way to do so. Sometimes we may want to
select not the elements with specified descendents themselves, but the
elements related to them, like preceding, descending, etc. Consider
the following document:

<UL>
    <LI>
    <LI><UL></UL>
    <LI>
</UL>

It is not possible for current selectors4 definition to write a
selector to represent LIs which follow a LI who has an UL inside.
There are many similar cases.

However, if we use pesudo-class instead, like :contains() or
:has-child(), the problem can be solved. For the example above, we can
use "LI:has-child(UL)~LI" to select the elements required.

IMO, this kind of notation looks more intuitive, and won't introduce
new symbols to complexify the grammar. And we would not need to worry
about whether the mark should be prepended or appended anymore. Just
drop it.

What do you think about this idea?

Regards,
Xidorn Quan
Received on Monday, 2 September 2013 16:26:44 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:31 UTC