Re: [csswg-drafts] [css-values] Proposal: add sibling-count() and sibling-index() (#4559)

Current state of proposed `sibling-index` / `tree-depth` functions FMPoV lacks (or fails to clearly show capability of) quite desired features compared to what `counter-increment` can do already:
- **skip** some siblings,
- fine grain what exactly participates on the resulting value: e.g. take attributes or **nesting** level into account.

Both are possible using `counter-increment` and standard selectors, as illustrated.
Counters displayed in `content` are meant to be available for other CSS functions or custom properties:

```CSS
/* fig.1: skip hidden <tabs><tab>(1)</tab><tab hidden>(skipped)</tab><tab>(2)</tab></tabs> */
tabs { counter-reset: index; }
tabs > tab:not([hidden])::before { counter-increment: index; content: 'Index: ' counter(index); }

/* fig.2: nesting depth <p><em>(1)<em>(2)<em>(3)</em></em><em>(2)</em></em></p> */
p { counter-reset: depth; }
p em::before { counter-increment: depth; content: 'Depth: ' counter(depth); }
p em::after { counter-increment: depth -1; content: ''; }
```
I think above use cases are quite relevant for problem in question.  Unless current proposal will be expanded so that
- problem depicted in `fig.1` could be solved with something like
`tabs > tab{--index: sibling-index(:not([hidden])); }`
(function argument filters previous siblings), 
- and problem from `fig.2` with something like
`p em{--depth: tree-depth(:has(> em)); }`
(function argument filters parents chain),

(yes, using _selectors_ in _properties_ feels super weird), or any other way, I'd rather lean towards #1026.

----
Please pardon unasked intervention and errors; I don't follow all conversations around here, so this had very likely been discussed before; I just felt it should be mentioned here.

-- 
GitHub Notification of comment by myfonj
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4559#issuecomment-571157758 using your GitHub account

Received on Monday, 6 January 2020 14:28:33 UTC