Re: [css-selectors] descentant up to a certain depth

Hr Gwea <[email protected]> Sun, 3 Jul 2016 16:28:04 -0400
Newsgroups gmane.comp.web.css.general
Message-ID <CAE++px-8ywKjvssgaGJpshNa2AvA_kdGczQf2rzv0KyoYw-o4g@mail.gmail.com>
Ok, that reduces the duplication a bit, but still requires elem1 and elem2
to be named explicitly twice. Which is not convenient when elem1 and elem2
are complex selectors.

I was thinking of the possibility to pass parameters to the descendant
combinator.
For example:

elem1 >(3)> elem2  /*descendants up to third level*/
elem1 >(2,5)> elem2  /*descendants from second to fifth level*/
elem1 >(1)> elem2  /*same as child combinator*/

How do you like it?



On Sun, Jul 3, 2016 at 12:03 PM, Brad Kemper <[email protected]> wrote:

>
> > On Jul 2, 2016, at 7:51 PM, Hr Gwea <[email protected]> wrote:
> >
> > Is there any plans or ideas to simplify selectors like this:
> >
> > elem1 > elem2,
> > elem1 > * > elem2,
> > elem1 > * > * > elem2 {...properties...}
> >
> > i.e. all elem2 that are children, grandchildren or great-grandchildren
> of elem1.
> > More generally, a descendant combinator that let us specify the max
> depth of the descendants
>
> In selectors 4, :not() can take a selector list.
>
> elem1 elem2:not(elem1 * * * elem2) {
>   /* should do what you want */
> }
>
> > If not, can I propose a solution?
>
> You can always propose.