{"record":{"id":"376e420886021dff","repo":"amruthpillai/reactive-resume","slug":"selector-list-has-an-unsupported-number-of-selecto","errorCode":null,"errorMessage":"Selector list has an unsupported number of selectors.","messagePattern":"Selector list has an unsupported number of selectors\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/resume/src/stylesheet/selector.ts","lineNumber":274,"sourceCode":"\t\t\tcontinue;\n\t\t}\n\n\t\tconst selector = compileSimple(child, context);\n\t\tif (selector) selectors.push(selector);\n\t}\n\n\tif (selectors.length === 0 && compounds.length > 0) throw new Error(\"Selector cannot end with a combinator.\");\n\tvalidateCompound(selectors);\n\tcompounds.push({ selectors });\n\tconst specificity = SpecificityCalculator.calculateForAST(node).toArray();\n\treturn { compounds, combinators, specificity: [specificity[0], specificity[1], specificity[2]] };\n}\n\nfunction compileSelectorList(node: SelectorAst, context: CompileContext): readonly CompiledComplexSelector[] {\n\tif (node.type !== \"SelectorList\") throw new Error(\"Expected a SelectorList AST.\");\n\tconst selectors = childrenOf(node);\n\tif (selectors.length === 0 || selectors.length > SEMANTIC_CSS_LIMITS_V1.maxSelectorsPerRule) {\n\t\tthrow new Error(\"Selector list has an unsupported number of selectors.\");\n\t}\n\treturn selectors.map((selector) => compileComplex(selector, context));\n}\n\nexport function compileSelector(source: string | CssNode): CompileSelectorResult {\n\ttry {\n\t\tconst text = typeof source === \"string\" ? source : csstree.generate(source);\n\t\tif (Array.from(text).length > SEMANTIC_CSS_LIMITS_V1.maxSelectorCodePoints)\n\t\t\tthrow new Error(\"Selector is too long.\");\n\t\tconst ast = (\n\t\t\ttypeof source === \"string\" ? csstree.parse(source, { context: \"selectorList\", positions: true }) : source\n\t\t) as SelectorAst;\n\t\treturn { selector: { selectors: compileSelectorList(ast, { depth: 0 }) } };\n\t} catch (error) {\n\t\treturn { selector: null, error: error instanceof Error ? error.message : \"Invalid selector.\" };\n\t}\n}\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/resume/src/stylesheet/selector.ts#L256-L292","documentation":"Thrown by compileSelectorList when the number of comma-separated complex selectors in a single selector list is zero or exceeds SEMANTIC_CSS_LIMITS_V1.maxSelectorsPerRule (64). The lower bound (zero) guards against malformed/empty input; the upper bound caps the combinatorial matching cost since each selector in the list is independently compiled and matched against every node. This limit applies per rule, not per stylesheet.","triggerScenarios":"Passing an empty selector list to compileSelector (css-tree parses an empty string into a SelectorList with zero children). Authoring a rule with more than 64 comma-separated selectors like 'a, b, c, ..., <65th>'. Programmatic generation that expands a template into a huge comma-separated list without chunking.","commonSituations":"Auto-generated stylesheets that enumerate many node kinds in one rule instead of using semantic attributes/roles. Accidental empty-string compilation when a dynamic selector source is uninitialized. Bulk import of external CSS that was written for a full browser engine rather than the restricted semantic subset.","solutions":["If the error is from an empty source, ensure the selector string is non-empty and valid before calling compileSelector.","If over the limit, split the single oversized selector list into multiple rules each with <= 64 selectors, or refactor to use :is() to group related targets into fewer list entries.","Prefer semantic attribute/role selectors over long enumerations of element types — one 'item[role=\"list-item\"]' replaces dozens of enumerated selectors.","Validate the selector count before compilation if generating programmatically, and chunk the output."],"exampleFix":"// before: 65+ comma-separated selectors\nconst source = 'a, b, c, /* ...65 total... */';\nconst { error } = compileSelector(source);\n// error === 'Selector list has an unsupported number of selectors.'\n\n// after: use :is() to group, or split into multiple rules\nconst source = ':is(a, b, c)';\nconst { selector, error } = compileSelector(source);","handlingStrategy":"validation","validationCode":"const MAX_SELECTORS = 64; // SEMANTIC_CSS_LIMITS_V1.maxSelectorsPerRule\nfunction countSelectorList(source: string): number {\n  return source.split(',').length;\n}\nif (countSelectorList(source) === 0 || countSelectorList(source) > MAX_SELECTORS) {\n  // chunk or reject\n}","typeGuard":"function selectorListSizeOk(source: string): boolean {\n  const n = countSelectorList(source);\n  return n > 0 && n <= 64;\n}","tryCatchPattern":"const { selector, error } = compileSelector(source);\nif (!selector && /unsupported number of selectors/.test(error)) {\n  // split the rule into chunks of <= 64 selectors\n}","preventionTips":["Avoid enumerating many element types; use role/attribute selectors instead.","Chunk generated comma lists to stay under 64 per rule.","Reject empty selector input before compilation."],"tags":["css","semantic-stylesheet","selector","limit"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}