{"record":{"id":"f993ae0a90fa3831","repo":"swc-project/swc","slug":"expected-ident-or-delim-tokens","errorCode":null,"errorMessage":"Expected ident, '*' or '|' delim tokens","messagePattern":"Expected ident, '\\*' or '\\|' delim tokens","errorType":"validation","errorClass":"swc_css_parser::error::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/selectors/mod.rs","lineNumber":516,"sourceCode":"                return Ok(TypeSelector::TagName(TagNameSelector {\n                    span: span!(self, span.lo),\n                    name: WqName {\n                        span: span!(self, span.lo),\n                        prefix,\n                        value,\n                    },\n                }));\n            }\n            tok!(\"*\") => {\n                bump!(self);\n\n                return Ok(TypeSelector::Universal(UniversalSelector {\n                    span: span!(self, span.lo),\n                    prefix,\n                }));\n            }\n            _ => {\n                return Err(Error::new(\n                    span,\n                    ErrorKind::Expected(\"ident, '*' or '|' delim tokens\"),\n                ));\n            }\n        }\n    }\n}\n\nimpl<I> Parse<NamespacePrefix> for Parser<I>\nwhere\n    I: ParserInput,\n{\n    fn parse(&mut self) -> PResult<NamespacePrefix> {\n        let span = self.input.cur_span();\n\n        let mut namespace = None;\n\n        match cur!(self) {","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/selectors/mod.rs#L498-L534","documentation":"A type selector is a namespace prefix (optional) followed by either an element name (ident) or the universal selector '*'. After an optional prefix was handled, the current token is neither an ident nor '*', so there is no type selector to build. This includes the case where a namespace prefix ('ns|') was consumed but no name or '*' follows it.","triggerScenarios":"'ns| { }' or 'ns|.a { }' (prefix with no tag/universal after the bar), a bare '|' followed by junk, or any type-selector position where the token is a delimiter, string, or EOF-adjacent token.","commonSituations":"Namespace-prefixed selectors (SVG/MathML, XML pipelines) where the element after '|' was typo'd or stripped by minification; templating that interpolates an empty tag name; copy-paste of namespace examples into plain HTML CSS where the prefix is then dangling.","solutions":["Complete the selector: 'ns|div {}' or 'ns|* {}'","Drop the namespace prefix if you do not need it: 'div {}'","Check for a stray '|' from a mis-escaped character ('a\\|b' vs 'a|b')","Lint selectors for a dangling '|' followed by non-name tokens"],"exampleFix":"/* before */\nns| { color: red; }\n/* after */\nns|* { color: red; }","handlingStrategy":"validation","validationCode":"// A '|' must be followed by an ident or '*'\nfunction noDanglingNamespaceBar(sel) { return !/\\|(?!\\s*[\\w*-])/.test(sel); }","typeGuard":"// Rust\nfn type_selector_tail_ok(rest: &str) -> bool {\n  let t = rest.trim_start();\n  t == \"*\" || t.chars().next().map_or(false, |c| c.is_ascii_alphabetic() || c == '_' || c == '-')\n}","tryCatchPattern":"// JS\ntry { parseSelector(sel, opts); } catch (e) { if (/ident, '\\*' or '\\|'/.test(e.message)) reportDanglingNamespace(sel); else throw e; }","preventionTips":["Escape literal '|' in selectors as '\\|'","When interpolating tag names, fall back to '*' when the name slot is empty"],"tags":["css","selector","namespace","syntax"],"backgroundTag":"css-selector-syntax-error","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}