[csswg-drafts] [selectors-4] need "first-matching-sibling" combinator (#3813)

v-python has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] need "first-matching-sibling" combinator ==
The current sibling combinators are:

+ select immediately following sibling if it matches
~ select any following siblings that match

Neither of these can be used to select the first following sibilng that matches. Or the 2nd. I only need the first, in my current application, but could imagine that someone might need the Nth.

This type of selection becomes useful when dealing with a grid containing hundreds or thousands of child elements of different types or classes. Yep, I have such. So the relationships between siblings become far more important when siblings become far more numerous.

It doesn't seem that one can apply the currently defined :first-* to the subset of siblings selected by ~, as those all apply based on parentage, not a selected subgroup.

Some syntax ideas:

A: S1 ~1 S2 
    S1 ~2 S2
    ...

B: some other special character than ~ to just mean first, if Nth doesn't sound useful.

C: some new pseudo-class that selects among a group  :first-that-matches( selector ), nth-that-matches( selector ), :last-that-matches( selector ), :nth-last-that-matches( selector ).  In this syntax, one would write  S1 ~ :first-that-matches( S2 )

D: S1 ~:first S2
    S1 ~:nth( n-expression ) S2
    S1  ~:last S2
    S1 ~:nth-last( n-expression ) S2

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3813 using your GitHub account

Received on Monday, 8 April 2019 05:14:25 UTC