- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Wed, 30 Jul 2008 18:45:40 -0500
- To: "www-style list" <www-style@w3.org>
- Message-ID: <dd0fbad0807301645t51948d03xf348be6ed9af9068@mail.gmail.com>
This is lifted from the :has-child proposal thread, since at least one person (Brad Kemper) liked the syntax, and at least one implementor (Boris Zbarsky) thought it wouldn't be horrible for implementations (at least, no more horrible than current child and sibling combinators). Thought I'd give it a proper write-up, since I've had reason to want it in the last week. *:matches pseudo-class* The :matches(*selector fragment*) pseudo-class represents an element that has another specified element *after *it in the document tree. The selector fragment starts with either the child combinator (>) or the adjacent-sibling combinator (+), optionally followed by whitespace, followed by a simple selector (see Selectors Level 3 for the definition of a simple selector). This matches if an element matched by the simple selector occurs as a child (if > was used) or following adjacent sibling (if + was used) of the target element. If the selector fragment is invalid or empty, the entire selector is invalid. Examples: td:matches(> input:checked) /* Matches any td with a checked input as a direct child */ h1:matches(+ ul) /* Matches any h1 which is directly followed by a <ul> */ p:matches(+ p) /* In a string of sibling <p>s, matches all but the last. Contrast with "p+p", which matches all but the first. */ tr:matches( input:checked) /* Invalid, as descendant combinator is not allowed */ div:matches(> p > samp) /* Invalid, as combinator is not followed by a simple selector */ Future extensions may relax the restrictions on the selector fragment, such as allowing it to take more combinators (such as the descendant or general sibling combinators) or allowing more than a simple selector in the selector fragment. ~TJ
Received on Wednesday, 30 July 2008 23:46:20 UTC