-
Notifications
You must be signed in to change notification settings - Fork 673
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
[css-contain] Allow container query style features to evaluate in a boolean? #8127
Comments
+1 to this. There are use cases, and it's congruent with the principle of least surprise, since all other types of queries support this. In fact, this seems straightforward enough that maybe we can resolve on async? |
+1 to this, here's an example where I needed it to reduce redundancy: https://codepen.io/una/pen/LYBrYGX. If I could check for the presence of the |
@astearns @atanassov do you think we could resolve async on this? |
This should be defined in a way that also works with standard properties as well as custom properties, right? If the query is checking for a value other than 'guaranteed invalid', that would only work on custom properties. Would we check for a value other than the defined initial value? Or would we need some other definition of truthy/falsey values? |
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e
Can this be resolved async for both custom properties and regular properties, or does the definition need to be worked through first? Please add a proposed resolution if you want to go the async route |
I think the definition is pretty straightforward: it evaluates to |
Checking |
Good point, for regular properties this is much more likely to match author expectations. |
What is It's kind of funky, but according to how we're discussing this, I would expect But because of this confusion ^ we should define if this is a "presence" query or if this a boolean query and discuss it as such. |
@Loirooriol It's unfortunately not possible to check |
It's not a boolean query, but "evaluated in a boolean context", which is phrased like that because that's how the same thing is phrased in the media queries spec, which basically means evaluated without a value/comparison. |
The CSS Working Group just discussed
The full IRC log of that discussion<emeyer> miriam: Container query style features can query custom properties, so the question is, can you query without the value to see if it has initial value<emeyer> …Thus getting true or false back <emeyer> …False if it’s the default value, true if it’s changed <Rossen_> q? <fantasai> sgtm <fremy> +1 <lea> +1 obvs <emeyer> dholbert: Would anything special be needed for Houdini registered properties? <emeyer> miriam: Yes, you’d be checking to see if it’s the initial value, by default that would be the guaranteed value <TabAtkins> s/guaranteed value/guaranteed-invalid value/ <emeyer> Rossen: Any questions or objections? <emeyer> (silence) <fantasai> RESOLVED: style queries can accept properties in boolean context; false if matches initial value, true otherwise |
Per resolution in w3c#8127, style() queries can query properties without a value which evaluates to true if the computed value is different from the initial value for that property.
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e
Per resolution in #8127, style() queries can query properties without a value which evaluates to true if the computed value is different from the initial value for that property. Co-authored-by: Rune Lillesveen <[email protected]>
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964}
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964}
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964}
Note: it may also have to be updated with is a property name or is the same as for a declaration [...], the basic syntax can be simplified to In #8735, I ask for clarifications about (Sorry if I am using grammar and syntax terms incorrectly/inappropriately) If |
@cdoublev Good catch, and it makes a difference because it decides whether these cases evaluate to
How about reverting the syntax change and instead change the prose to something like: "The syntax of a That would result in all of the style() queries in the block above to fall back to Does that look reasonable? |
Entirely. I have no strong opinion but I would say that |
This would exclude custom properties, wouldn't it? |
@container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964}
…le() queries, a=testonly Automatic update from web-platform-tests [@container] Support boolean context style() queries @container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964} -- wpt-commits: c9d16e205399c4a7fe1932748e01ac1315a1853e wpt-pr: 38320
I think I caused a bit of confusion, sorry. The evaluation of the query may not directly depend on the result of parsing. I stand by my suggestion and extend it:
https://drafts.csswg.org/css-contain-3/#typedef-style-feature
|
Remove the recently added grammar part for style-feature that was inaccurate. Do not accept invalid declarations or unsupported property names as a style-feature. The effect of that is that we do not need to store invalid declarations, but merely fall back to parse the style() query with the invalid declaration as a general-enclosed, which will evaluate to unknown.
You mean the "supported property name" part? Custom property declarations are valid declarations, right? I would like to avoid is having to parse and store invalid declarations. So where the current spec says that invalid property names and values evaluate to unknown, I'd rather make style() queries with invalid declarations fall back to general-enclosed parsing which would also evaluate to unknown. |
…le() queries, a=testonly Automatic update from web-platform-tests [@container] Support boolean context style() queries @container style(--foo) is syntactic sugar for: @container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1132964} -- wpt-commits: c9d16e205399c4a7fe1932748e01ac1315a1853e wpt-pr: 38320
https://drafts.csswg.org/cssom-1/#supported-css-property I borrowed if it accepts that property in a style rule from the prose in CSS Conditionals 3 for |
Got it. How about:
I'm not able to understand what you're trying to say here. Where did you borrow that? |
Oh, sorry.
In the next part of my comment (which I should have split), I say that I would have no problem if |
…e() queries, a=testonly Automatic update from web-platform-tests [container] Support boolean context style() queries container style(--foo) is syntactic sugar for: container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <findit-for-meappspot.gserviceaccount.com> Reviewed-by: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1132964} -- wpt-commits: c9d16e205399c4a7fe1932748e01ac1315a1853e wpt-pr: 38320 UltraBlame original commit: ae1485857d9c0b134901e2b35661c6dc48820cfb
…e() queries, a=testonly Automatic update from web-platform-tests [container] Support boolean context style() queries container style(--foo) is syntactic sugar for: container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <findit-for-meappspot.gserviceaccount.com> Reviewed-by: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1132964} -- wpt-commits: c9d16e205399c4a7fe1932748e01ac1315a1853e wpt-pr: 38320 UltraBlame original commit: ae1485857d9c0b134901e2b35661c6dc48820cfb
…e() queries, a=testonly Automatic update from web-platform-tests [container] Support boolean context style() queries container style(--foo) is syntactic sugar for: container not style(--foo: initial) w3c/csswg-drafts#8127 Bug: 1302630 Change-Id: I087207e11df858ac325610d935a4c303e5503e0e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209086 Code-Coverage: Findit <findit-for-meappspot.gserviceaccount.com> Reviewed-by: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1132964} -- wpt-commits: c9d16e205399c4a7fe1932748e01ac1315a1853e wpt-pr: 38320 UltraBlame original commit: ae1485857d9c0b134901e2b35661c6dc48820cfb
Thanks for the clarifications. I have a PR here: #8756 It doesn't express it the way you suggest, but should mean the same. We can continue further discussions there. Added you as a reviewer in case you want to take a look. |
* [css-contain-3] Tweak the spec for style() queries #8127 Remove the recently added grammar part for style-feature that was inaccurate. Do not accept invalid declarations or unsupported property names as a style-feature. The effect of that is that we do not need to store invalid declarations, but merely fall back to parse the style() query with the invalid declaration as a general-enclosed, which will evaluate to unknown. * Reformulate and add general-enclosed evaluation --------- Co-authored-by: Rune Lillesveen <[email protected]>
Dimensional media/container queries can evaluate in a boolean context. This isn't terribly useful (dimensional queries aren't the main use-case for booleans), but it works:
With style queries, a boolean check is much more useful:
I think all these checks are possible in the current spec by querying for
initial
and negating the query, so allowing boolean queries would just be syntax sugar:The text was updated successfully, but these errors were encountered: