Skip to content

[css-contain] <container-name> in @container ambiguities #7203

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
emilio opened this issue Apr 7, 2022 · 8 comments
Closed

[css-contain] <container-name> in @container ambiguities #7203

emilio opened this issue Apr 7, 2022 · 8 comments

Comments

@emilio
Copy link
Collaborator

emilio commented Apr 7, 2022

Two thoughts:

  • <container-name> kinda conflicts with <container-condition>, as not can be a valid <container-name>, how should @container not (width > 300px) be parsed? There's an obvious answer, but probably that means that not should not be a valid <container-name>?

  • Per spec <container-name> includes none and multiple <custom-idents>, is @container foo bar (width > 300px) expected to be valid? I don't see any test for multiple container names in the rule, so just checking whether that's intentional or not.

cc @andruud @mirisuzanne @anttijk

@mirisuzanne
Copy link
Contributor

  • I agree, we should disallow not as a <container-name>
  • I don't think we want none in the @container <name> syntax, so should probably clarify that production either way. I would lean towards allowing multiple names in a query, and defining them to act as a combined filter, so that a container for your query would have to match both foo AND bar names. It's more important that we allow multiple names on a container itself (the property), but given that containers may have multiple names, it seems useful that you could be more explicit about combinations of names that need to be present for a query.

lilles added a commit to lilles/csswg-drafts that referenced this issue May 20, 2022
lilles added a commit to lilles/csswg-drafts that referenced this issue May 20, 2022


Use a separate definition of container-name in the @container syntax to
disallow 'none' and 'not'.
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-contain] <container-name> in @container ambiguities, and agreed to the following:

  • RESOLVED: disallow 'not' as a container name
  • RESOLVED: 'none', 'not', 'and', and 'or' would be disallowed. Only a single name allowed in @container rule
The full IRC log of that discussion <dael> Topic: [css-contain] <container-name> in @container ambiguities
<dael> github: https://github.com//issues/7203
<dael> miriam: The way we have container-name at the start of an @container rule can be confused currently with keyword not
<fantasai> +1 to disallowing not
<TabAtkins> +1 to disallow "not"
<dael> miriam: @container might start with either container-name or not. First part is to disallow 'not' as a container name
<jensimmons> +1 seems obvious to me
<dael> Rossen_: I see support
<dael> Rossen_: Should be straightforward. Other opinions? Or objections?
<dael> RESOLVED: disallow 'not' as a container name
<dael> miriam: Next part is a question. not clear if you can query multiple names in an @container rule and what happens if you did. and or or condition?
<dael> miriam: Container can have multiple names. You can say if you use multiple names you need both or all. Or say this or that. Or disallow multiple names
<dael> miriam: Sort of use cases of any of the above. And all can be handled by other naming conventions. no clear reason to go one way or another
<dael> miriam: Most obvious to me if we allow multiple names is they're allr equired
<Rossen_> ack fantasai
<dael> fantasai: I think ligit use cases for AND and OR so logical thing to do is apply bool syntax here. Might not want to do that b/c that's adding a lot. I suggest only 1 container name, disallow not, and, and or. Consider in the future if we want a more powerful syntax
<dael> Rossen_: Reserve the bool names for now, only allow 1 container name, and that gives us future extensibility for bool and multi naming
<dael> miriam: Makes sense to me
<dael> fantasai: miriam you mentioned about disallowing none?
<dael> miriam: So none can't be the name of a container. none as a container name just removes container names. I don't think need to explicitly disallow, but could clarify that
<dael> fantasai: Makes a difference as to if rule is invalidated. I lean toward invalidating it
<dael> miriam: 'none', 'not', 'and', and 'or' would be disallowed. Only a single name allowed in @container rule
<dael> Rossen_: Sounds like a good summary. Opinions or objections?
<dael> RESOLVED: 'none', 'not', 'and', and 'or' would be disallowed. Only a single name allowed in @container rule

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 9, 2022
See resolution: w3c/csswg-drafts#7203

Bug: 1145970
Change-Id: I0309c153354ac5f299ab63562db8a279a24728a1
aarongable pushed a commit to chromium/chromium that referenced this issue Jun 9, 2022
See resolution: w3c/csswg-drafts#7203

Bug: 1145970
Change-Id: I0309c153354ac5f299ab63562db8a279a24728a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698402
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012619}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 9, 2022
See resolution: w3c/csswg-drafts#7203

Bug: 1145970
Change-Id: I0309c153354ac5f299ab63562db8a279a24728a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698402
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012619}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 9, 2022
See resolution: w3c/csswg-drafts#7203

Bug: 1145970
Change-Id: I0309c153354ac5f299ab63562db8a279a24728a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3698402
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012619}
mirisuzanne added a commit that referenced this issue Jun 9, 2022
…20520

[css-contain-3] Exclude 'none' and 'not' from custom-ident. #7203
mirisuzanne added a commit that referenced this issue Jun 9, 2022
[css-contain-3] Disallow not/none for container-name in @-rule. #7203
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 13, 2022
…ontainer-name>, a=testonly

Automatic update from web-platform-tests
[@container] Disallow and/not/or from <container-name>

See resolution: w3c/csswg-drafts#7203

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

--

wpt-commits: 8f01d1edf99d842218f5446b9fd6e0d2dc47c3db
wpt-pr: 34360
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Jun 14, 2022
…ontainer-name>, a=testonly

Automatic update from web-platform-tests
[@container] Disallow and/not/or from <container-name>

See resolution: w3c/csswg-drafts#7203

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

--

wpt-commits: 8f01d1edf99d842218f5446b9fd6e0d2dc47c3db
wpt-pr: 34360
@yisibl
Copy link
Contributor

yisibl commented Jul 12, 2022

Can the specification add examples or other instructions to further clarify the not case? (I can submit a PR)

Implementers are still susceptible to misunderstandings or misinterpretations. see: parcel-bundler/lightningcss#158 (comment)

That's not what the grammar in the spec says though. I don't see a test that implies it either. It only tests that not is not a valid container name, not that it can't start a condition.

@devongovett
Copy link
Contributor

devongovett commented Jul 12, 2022

The grammar says:

@container [ <container-name> ]? <container-condition> {

... 

<container-name> = <custom-ident>
<container-condition> = not <query-in-parens>
                      | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]

...

The keywords none, and, not, and or are excluded from the <custom-ident> above.

This leads me to believe that @container not (width <= 500px ) is valid, with the not being interpreted as part of the container condition rather than the name. The not <query-in-parens> case doesn't seem to require parentheses around it. I would also expect @container name not (width <= 500px) to be valid based on this grammar.

Chromium seems to disallow this and require parens around the condition. Is this a bug, or should the grammar be updated to match? Am I misinterpreting the spec somehow?

FWIW, Safari TP and Firefox dev edition seem to still treat not as the name rather than part of the condition. No browser is able to parse @container name not (width <= 500px) at all.

@mirisuzanne
Copy link
Contributor

Yes, both of these are valid, with not being part of the condition rather than the name. If implementations are getting that wrong, we should at least create a WPT, and file bugs - and potentially clarify the spec.

@container not (width <= 500px ) { … }
@container name not (width <= 500px) { … }

@devongovett
Copy link
Contributor

Opened a PR to add a test here: web-platform-tests/wpt#34849. There was also one incorrect test, which might have contributed to implementations getting this wrong.

@lilles
Copy link
Member

lilles commented Jul 25, 2022

Since the spec changed without test changes after the implementation/tests were written, the spec change went unnoticed and the previous syntax is what's currently implemented in both Chrome and Safari.

@lilles
Copy link
Member

lilles commented Jun 20, 2023

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

6 participants