From f6249f30b171de34c41343a8342f8cde1f2720d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Legi=C4=99=C4=87?= Date: Thu, 16 Apr 2026 11:40:28 +0200 Subject: [PATCH 1/2] fix: include container-query type in patch output The patched container-condition and query-in-parens types reference , but it was never included in the output. This is because both raw data sources define container-query identically, so diff_sets() excludes it. When consumed with a css-tree version that lacks container-query in its base grammar, fork() cannot resolve the reference and throws "Bad syntax reference". Added container-query to the manual compatibility patches (same pattern as dashed-ident and unicode-range-token) and a test verifying the type is present in the output. --- .../dist/index.json | 1 + .../scripts/apply-patches.mjs | 1 + .../tests/container-query.test.mjs | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 packages/css-syntax-patches-for-csstree/tests/container-query.test.mjs diff --git a/packages/css-syntax-patches-for-csstree/dist/index.json b/packages/css-syntax-patches-for-csstree/dist/index.json index 79bc0cc35..84a67a63e 100644 --- a/packages/css-syntax-patches-for-csstree/dist/index.json +++ b/packages/css-syntax-patches-for-csstree/dist/index.json @@ -435,6 +435,7 @@ "types": { "dashed-ident": "", "unicode-range-token": "", + "container-query": "not | [ [ and ]* | [ or ]* ]", "alpha()": "alpha( [ from ] [ / [ | alpha | none ] ]? )", "an+b": "odd | even | | | '+'? n | -n | | '+'? | | | '+'? n | -n | | '+'? n- | -n- | [ '+' | '-' ] | '+'? n [ '+' | '-' ] | -n [ '+' | '-' ] ", "anchored-feature": "fallback : <'position-try-fallbacks'>", diff --git a/packages/css-syntax-patches-for-csstree/scripts/apply-patches.mjs b/packages/css-syntax-patches-for-csstree/scripts/apply-patches.mjs index ad169a672..88ea835cf 100644 --- a/packages/css-syntax-patches-for-csstree/scripts/apply-patches.mjs +++ b/packages/css-syntax-patches-for-csstree/scripts/apply-patches.mjs @@ -108,6 +108,7 @@ export function apply_patches(patches, onto) { // Manual patches to smooth over compat between csstree and webref/css types['dashed-ident'] = ''; types['unicode-range-token'] = ''; + types['container-query'] = 'not | [ [ and ]* | [ or ]* ]'; for (const [name, definition] of Object.entries(onto.types)) { const patch = patches.types[name]; diff --git a/packages/css-syntax-patches-for-csstree/tests/container-query.test.mjs b/packages/css-syntax-patches-for-csstree/tests/container-query.test.mjs new file mode 100644 index 000000000..751399908 --- /dev/null +++ b/packages/css-syntax-patches-for-csstree/tests/container-query.test.mjs @@ -0,0 +1,26 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import fs from 'node:fs/promises'; +import path from 'path'; +import { fork, parse } from 'css-tree'; + +const patches = JSON.parse(await fs.readFile(path.join('dist', 'index.json'), 'utf-8')).next; + +test('container-query type is defined in patch output', () => { + assert.ok( + patches.types['container-query'], + 'container-query must be in patch output because container-condition and query-in-parens reference it', + ); +}); + +test('@container prelude validates without error', () => { + const forkedLexer = fork({ + atrules: patches.atrules, + properties: patches.properties, + types: patches.types, + }).lexer; + + const prelude = parse('(min-width: 768px)', { context: 'atrulePrelude', atrule: 'container' }); + const result = forkedLexer.matchAtrulePrelude('container', prelude); + assert.equal(result.error, null, `should validate @container prelude, got: ${result.error?.message}`); +}); From 2bfd803308b3f544500ec381eeec65c7c897de8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Legi=C4=99=C4=87?= Date: Thu, 16 Apr 2026 11:40:59 +0200 Subject: [PATCH 2/2] docs: add changelog entry for container-query fix --- packages/css-syntax-patches-for-csstree/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/css-syntax-patches-for-csstree/CHANGELOG.md b/packages/css-syntax-patches-for-csstree/CHANGELOG.md index d233ea481..847a0f286 100644 --- a/packages/css-syntax-patches-for-csstree/CHANGELOG.md +++ b/packages/css-syntax-patches-for-csstree/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes to CSS Syntax Patches For CSSTree +### Unreleased (patch) + +- Fixed missing `container-query` type definition in patch output + ### 1.1.3 _April 12, 2026_