-
Notifications
You must be signed in to change notification settings - Fork 719
[css-contain-4] Define a range syntax for style container queries #8376
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
Comments
For syntax, we can just adopt the MQ operators. I think it makes sense to require these properties to be registered as Or, crazy idea here, given this is fairly limited and these types can be detected syntactically, what if we don't require registration at all? Would that be possible? Is there any ambiguity I'm missing? |
I assume that includes the full range syntax, so one could write @container style(1em < padding < 3em) { … } Correct? Sebastian |
There is indeed no ambiguity when limited to comparisons of this type - there's no keywords or similar that can be interpreted differently on context, just plain numbers and dimensions. And math functions, which is the only thing that makes me slightly concerned, just due to the potential complexity. But I suspect it's fine. |
Another complexity: is it allowed to mention multiple properties? |
I'd suggest not, at first. |
That syntax doesn't make sense to me. I'd say we should stick to the syntax defined for media queries. So that could be expressed as Sebastian |
Yeah, agreed that we should stick to the MQ syntax for now - either a property compared to a literal, or a property sandwiched between two literal comparisons. |
I marked this for contain-4, but not sure if it needs to be deferred from l3? It doesn't seem like a big lift on the spec side, but may be a larger consideration for implementors? |
I just mentioned this in the older thread, but this would be a very useful feature. And +1 to the MQ range syntax as a mechanism to query values by. |
We would need to limit (and define the limitations) of the syntax options for range queries? I.e. Valid: Invalid: |
Yes, it would be all the numeric types. Not colors, tho. |
@lilles raised a question this morning about how to resolve |
Percents aren't comparable to lengths in contexts where they don't resolve against a length, so they'd just be false, I suppose? That is, (Do we want to try and do syntax validation on known properties? Or should we just consider them the same way, where doing a nonsensical comparison like |
I think it would be ok to do without parse-time syntax validation - but I would probably expect |
We don't use unknown for "this doesn't make sense", we use it for "this conceivably has a true/false answer, but we happen to not know what it is; a future browser might, tho". So nonsense comparisons are simply false, not unknown. And in a custom property, %s do not resolve against anything, so they're incomparable with any other types, just as much as lengths and angles are incomparable. |
Are we going with the idea that registration isn't required, but the custom property side is interpreted according to the type of the literal side? |
Right; registration doesn't add anything to the equation in this case. If we see I mean, maybe registration lets you fast-path a false for nonsensical comparisons, but that's it. Tho hm, do we ever want to allow something like |
Great, just wanted to clarify that so we know what to implement.
It could work without as well? We just try to parse a numeric thing on both sides, and check if they're compatible. |
Yeah true. |
Does this logic seem like something we could add to css-contain-3, or would need to be deferred to L4? |
This also seems to have implications for the non-range syntax, yeah? Like, we'd want (I think this is fine, fwiw.) |
Should we consider making EDIT: It seems risky to always interpret things as Having multiple behaviors for the same operator also feels shaky. It would be better if |
I like the consistency, and since authors have both options, they can opt into either behavior. |
...
...
This has marinated for ~two years: can we make progress here now? Proposal:
For e.g. style(A > B):
Note that this allows Note also that you can't compare a |
I don't think there is any reason to disallow this, as this can be a quite common use. Probably not on its own (although, you could want to check the value of
Hmm, as an author, I would expect the |
I like the proposal, and would love for it to move forward.
There would be other versions of this that are less useful (px vs inch?) - but this seems like it would have solid use cases, since
Me too |
Sure, OK. Note, however, that this is more like @property --x {
syntax: " But we can certainly still make |
Given #11104, is it dumb that both |
Yes, as far as I understand, they mean the same thing. |
For discussion sake, the proposal is here: #8376 (comment) - follow-up comments provide some additional details and clarifications. |
If we're accepting |
The CSS Working Group just discussed
The full IRC log of that discussion |
With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710}
With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710}
With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710}
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946
Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1465578}
Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1465578}
Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1465578}
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946 UltraBlame original commit: 37eba09f6ad439be60cf6025ef61bf9f52e7b15b
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946 UltraBlame original commit: 37eba09f6ad439be60cf6025ef61bf9f52e7b15b
…es ranges, Automatic update from web-platform-tests Support parsing of container style queries ranges With range style queries, now we can define any non empty values in range values. Apart from that, the syntax is mostly like media queries ranges, [0]. Resolved in [1]. [0] https://www.w3.org/TR/mediaqueries-5/#typedef-mf-range [1] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: I828805406698d40c28a1d62d1b3de4cc1b493c94 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6549116 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1462710} -- wpt-commits: fcdebf414acbe5a29b7453c2036567ec94b47b03 wpt-pr: 52666 Differential Revision: https://phabricator.services.mozilla.com/D250946 UltraBlame original commit: 37eba09f6ad439be60cf6025ef61bf9f52e7b15b
…n if(), Automatic update from web-platform-tests Evaluate range container style queries in if() Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1465578} -- wpt-commits: ed9846d475761ebb5c0aa451341482447f2c1bb8 wpt-pr: 52784 Differential Revision: https://phabricator.services.mozilla.com/D251826
…n if(), Automatic update from web-platform-tests Evaluate range container style queries in if() Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main@{#1465578} -- wpt-commits: ed9846d475761ebb5c0aa451341482447f2c1bb8 wpt-pr: 52784 Differential Revision: https://phabricator.services.mozilla.com/D251826
…n if(), Automatic update from web-platform-tests Evaluate range container style queries in if() Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1465578} -- wpt-commits: ed9846d475761ebb5c0aa451341482447f2c1bb8 wpt-pr: 52784 Differential Revision: https://phabricator.services.mozilla.com/D251826 UltraBlame original commit: d23c90f19fe87a6569668024d3936acebd4078d0
…n if(), Automatic update from web-platform-tests Evaluate range container style queries in if() Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1465578} -- wpt-commits: ed9846d475761ebb5c0aa451341482447f2c1bb8 wpt-pr: 52784 Differential Revision: https://phabricator.services.mozilla.com/D251826 UltraBlame original commit: d23c90f19fe87a6569668024d3936acebd4078d0
…n if(), Automatic update from web-platform-tests Evaluate range container style queries in if() Resolved in [0]. [0] w3c/csswg-drafts#8376 (comment) Bug: 408011559 Change-Id: Ided2356dae0981e31c70774419738f958f8b7636 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6582622 Reviewed-by: Anders Hartvoll RuudCommit-Queue: Munira Tursunova Cr-Commit-Position: refs/heads/main{#1465578} -- wpt-commits: ed9846d475761ebb5c0aa451341482447f2c1bb8 wpt-pr: 52784 Differential Revision: https://phabricator.services.mozilla.com/D251826 UltraBlame original commit: d23c90f19fe87a6569668024d3936acebd4078d0
The css-contain-3 spec provides a 'style container feature', allowing authors to query the computed value of a given property on the container. However, that query is currently limited to the declaration syntax, which provides a simple equality comparison:
As discussed in #7068, there are also use-cases for range comparisons on container properties:
For custom properties, this might require a defined syntax using
@property
? Or would we want a way to define the value type on the query itself? Thoughts?The text was updated successfully, but these errors were encountered: