Skip to content

[css-values-5] What does sibling-index()/sibling-count() return if there's no element? #11232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sesse opened this issue Nov 18, 2024 · 4 comments

Comments

@sesse
Copy link
Contributor

sesse commented Nov 18, 2024

sibling-index() (and its sibling, sibling-count()) does not seem to have defined behavior if there's no element, e.g. in a media query. What should the behavior here be? (Returning 0 would be fine by us, if you just want to pick something arbitrary.)

@Loirooriol
Copy link
Contributor

I don't think we should defer to the ultimate originating element at all, see #9573

@sesse sesse changed the title [css-values-5] What does sibling-index()/sibling-count() return if there's no originating element? [css-values-5] What does sibling-index()/sibling-count() return if there's no element? Dec 2, 2024
@lilles
Copy link
Member

lilles commented Mar 13, 2025

There is a question if it should parse at all. Some relevant cases are @media queries, @page properties, @font-face descriptors.

A similar case is anchor-size(). The spec handles anchor-size() as IACVT if not used in a sizing property, but whether anchor-size() should parse at all in a non-element context like the ones mentioned above is not clear to me.

Testing anchor-size() in Chrome turns out that it is valid at parse time for @page properties, but not for @font-face. Also, anchor-size() causes media queries to become general-enclosed.

Additionally, there is the case for @container queries where I think the obvious behavior is that sibling-index()/count() resolves against the container element like font relative units, which should probably have a clarifying comment in the spec for container queries.

@cdoublev
Copy link
Collaborator

cdoublev commented Mar 13, 2025

The spec handles anchor-size() as IACVT if not used in a sizing property, but whether anchor-size() should parse at all in a non-element context like the ones mentioned above is not clear to me.

In my opinion, this is an error in the spec. anchor() and anchor-size() are explicitly defined as New values of the set of properties for which they are valid. What would be the reason to accept them in any property value just to make them IACVT in most of them?

Fwiw, #10982 is a duplicate of this issue that is extended to other numeric substitution functions, which could also be extended to arbitrary substitution functions (cf. #10679 (comment)).

@lilles
Copy link
Member

lilles commented Mar 13, 2025

Right. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants