[selectors] Groups and repetition

Hi,

I was gonna start implementing the filtered sibling selector (http://lists.w3.org/Archives/Public/www-style/2014Oct/0210.html) in WebKit but it occurred to me that there is an other syntax with a simple implementation and more capabilities.

Instead of creating a special purpose indirect sibling, we could just extend the existing syntax by allowing groups and repetition, similarly to regular expressions.

Taking the examples already discussed:
    h1 ~(:not(h1, p)) p
Could be (using regexp �*� for 0-to-n repetition):
    h1 ( + :not(h1, p))* + p
Which is h1 following by any number of siblings matching :not(h1, p) followed by <p>.

The non-linked-image case:
	:root >>(:not(:any-link)) img
can be:
        :root (> :not(any-link))* > img

The advantage of this syntax over the other one is that you can express a much wider variety of relations.

I do not have strong use cases for this over the syntax �~(selector list)� but I wanted to raise this to see if there is any interest before spending time implementing the other option.

Benjamin

Received on Tuesday, 21 October 2014 01:47:31 UTC