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_ 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}`); +});