Skip to content

[css-values-5] Disallow mix/random/tree-counting functions in some contexts #10982

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

Open
cdoublev opened this issue Oct 1, 2024 · 6 comments
Open

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Oct 1, 2024

Based on comments in #10879, any value defined in CSS Values and Units should be valid in any context other than a property value, unless otherwise specified.

mix, random, tree couting functions, need an element, but are not explicitly disallowed in other contexts.

I would say they should be invalid in media queries and any descriptor value, and valid in the prelude of keyframe and @container rules. (It seems easier to find use cases in the prelude of keyframe rules.)

Perhaps defining the concept of element-dependent (substitution) value could help clarifying this: such value would be invalid in all contexts except those "associated" to an element, or that do not need to resolve its value (feature queries). var(), attr(), toggle(), <whole-value>, would be element-dependent subsitution values.

I do not know if any of these substitution functions should/can be valid in the HTML srcset attribute (to replace <length>), but invalid in the media attribute. I guess none is currently accepted, not even math functions.

@fantasai
Copy link
Collaborator

fantasai commented Oct 8, 2024

Some types of mix functions are reasonable to allow anywhere, they just represent the interpolation between two values and that's fine. We could also define something reasonable for random() outside of an element context. Agree with defining some kind of concept for element-dependent functions, though, and making such invalid (if they don't have a reasonable fallback behavior).

@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 9, 2024

Allowing them anywhere would require making some arguments (<'animation-timeline'>, per-element) invalid in these other contexts.

@lilles
Copy link
Member

lilles commented Mar 14, 2025

I was thinking they should be allowed in container queries, evaluating against the container element, but then the size query container may fall back to the viewport which is not an element.

@lilles
Copy link
Member

lilles commented Mar 14, 2025

@tabatkins @emilio @nt1m Any opinions on whether tree-counting functions like sibling-index() should be valid parse time in:

  • @page properties
  • descriptors for @font-face and other at-rules which do not apply directly to elements
  • @container queries (this is particularly interesting since the container element can be a natural choice most of the time)
  • @media queries

And if such functions are valid, what should they evaluate to.

aarongable pushed a commit to chromium/chromium that referenced this issue Mar 14, 2025
Tree-counting functions such as sibling-index() do not have a useful
interpretation in contexts where there are no elements involved. For
instance in @media queries and @font-face descriptors.

This is currently not per any specification, but there is an open issue
for it:

w3c/csswg-drafts#10982

We still allow sibling-index() in @page properties with this CL.

Bug: 40282719

Change-Id: I10b939d1981e9eb3347f18a7ef292cdd425b3cbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6352179
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1432625}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 14, 2025
Tree-counting functions such as sibling-index() do not have a useful
interpretation in contexts where there are no elements involved. For
instance in @media queries and @font-face descriptors.

This is currently not per any specification, but there is an open issue
for it:

w3c/csswg-drafts#10982

We still allow sibling-index() in @page properties with this CL.

Bug: 40282719

Change-Id: I10b939d1981e9eb3347f18a7ef292cdd425b3cbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6352179
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1432625}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Mar 14, 2025
Tree-counting functions such as sibling-index() do not have a useful
interpretation in contexts where there are no elements involved. For
instance in @media queries and @font-face descriptors.

This is currently not per any specification, but there is an open issue
for it:

w3c/csswg-drafts#10982

We still allow sibling-index() in @page properties with this CL.

Bug: 40282719

Change-Id: I10b939d1981e9eb3347f18a7ef292cdd425b3cbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6352179
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1432625}
@emilio
Copy link
Collaborator

emilio commented Mar 14, 2025

I think it makes sense to disallow them to begin with...

Only container queries really have something resembling a sensible behavior IMO, and what should the fallback behavior be is not particularly clear...

Disallowing it gives us more leeway to decide on what the right behavior should be once there are concrete use cases for it...

@tabatkins
Copy link
Member

Yeah, I'm fine with starting with them all disallowed, parse-time invalid. We can turn them on as requested.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Mar 18, 2025
…element contexts, a=testonly

Automatic update from web-platform-tests
Disallow tree-counting functions in non-element contexts

Tree-counting functions such as sibling-index() do not have a useful
interpretation in contexts where there are no elements involved. For
instance in @media queries and @font-face descriptors.

This is currently not per any specification, but there is an open issue
for it:

w3c/csswg-drafts#10982

We still allow sibling-index() in @page properties with this CL.

Bug: 40282719

Change-Id: I10b939d1981e9eb3347f18a7ef292cdd425b3cbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6352179
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1432625}

--

wpt-commits: ec3fe6dd156fe077571b3219eae3d7e49f1e9025
wpt-pr: 51353
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