Skip to content

feat: support name-only @container queries#1125

Merged
devongovett merged 1 commit intoparcel-bundler:masterfrom
yisibl:optional-container-query
Jan 20, 2026
Merged

feat: support name-only @container queries#1125
devongovett merged 1 commit intoparcel-bundler:masterfrom
yisibl:optional-container-query

Conversation

@yisibl
Copy link
Contributor

@yisibl yisibl commented Jan 9, 2026

In the CSS specification, <container-query> is now optional.

Old: [ <container-name> ]? <container-query>
New:[ <container-name>? <container-query>? ]!

This means that previously, to determine whether an element had container queries enabled, we had to write it like this:

@container foo (width >= 0) {
  .inner {
    color: green
  }
}

It can now be simplified to:

@container foo {
  .inner {
    color: green
  }
}

This PR also improves error messages; @container foo () {} now provides specific syntax error reasons:

The brackets cannot be empty

In the CSS specification, `<container-query>` is now optional.

Old: `[ <container-name> ]? <container-query>`
New:`[ <container-name>? <container-query>? ]!`

This means that previously, to determine whether an element had container queries enabled,
we had to write it like this:

```css
@container foo (width >= 0) {
  .inner {
    color: green
  }
}
```

It can now be simplified to:

```css
@container foo {
  .inner {
    color: green
  }
}
```

- Spec: w3c/csswg-drafts#11172
- Chrome implemented in: https://chromium-review.googlesource.com/c/chromium/src/+/7378819
- Safari implemented in: https://bugs.webkit.org/show_bug.cgi?id=302433

----

This PR also improves error messages; `@container foo () {}` now provides specific syntax error reasons:

```
The brackets cannot be empty
```
@yisibl yisibl force-pushed the optional-container-query branch from a74a409 to e6dc768 Compare January 9, 2026 10:00
@yisibl yisibl marked this pull request as ready for review January 9, 2026 10:00
@yisibl
Copy link
Contributor Author

yisibl commented Jan 12, 2026

@devongovett PTAL

@devongovett devongovett merged commit 0e7301a into parcel-bundler:master Jan 20, 2026
3 checks passed
@yisibl yisibl deleted the optional-container-query branch January 20, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants