{"record":{"id":"198bc0a9262ea8a5","repo":"OrchardCMS/OrchardCore","slug":"syntax-error-unrecognized-expression-jquery-slim","errorCode":null,"errorMessage":"Syntax error, unrecognized expression: ","messagePattern":"Syntax error, unrecognized expression: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/jquery-3.4.1/jquery.slim.js","lineNumber":1560,"sourceCode":"\t\tval = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?\n\t\t\tfn( elem, name, !documentIsHTML ) :\n\t\t\tundefined;\n\n\treturn val !== undefined ?\n\t\tval :\n\t\tsupport.attributes || !documentIsHTML ?\n\t\t\telem.getAttribute( name ) :\n\t\t\t(val = elem.getAttributeNode(name)) && val.specified ?\n\t\t\t\tval.value :\n\t\t\t\tnull;\n};\n\nSizzle.escape = function( sel ) {\n\treturn (sel + \"\").replace( rcssescape, fcssescape );\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n/**\n * Document sorting and removing duplicates\n * @param {ArrayLike} results\n */\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {","sourceCodeStart":1542,"sourceCodeEnd":1578,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/jquery-3.4.1/jquery.slim.js#L1542-L1578","documentation":"Same Sizzle.error throw as the full build: Sizzle throws new Error('Syntax error, unrecognized expression: ' + msg) when a selector string is not valid per its grammar. In jquery.slim.js this is the entry point for all unrecognized-expression errors from $(), find(), filter(), etc.","triggerScenarios":"$('') or other empty/invalid selector strings; unbalanced brackets/parens; unescaped metacharacters (., :, [, ]) in ids or attribute selectors; invalid pseudo-selectors like :unknown.","commonSituations":"Building selectors from dynamic/empty values; ASP.NET-generated ids containing dots used unescaped in jQuery selectors; typos in pseudo-classes; user-supplied filter expressions.","solutions":["Guard against empty/undefined selector strings before calling $()","Escape special characters with CSS.escape or manual backslash escaping","Correct the selector syntax (quote attribute values, balance brackets)","Log the offending selector to identify the dynamic source"],"exampleFix":"// before\n$(selector); // selector === ''\n// after\nif (typeof selector === 'string' && selector.trim()) { $(selector); }","handlingStrategy":"validation","validationCode":"function isSafeSelector(sel) { return typeof sel === 'string' && sel.trim().length > 0 && /^[A-Za-z0-9_#.:\\[\\]\"'=~|^$*>+~\\s\\-,(\\\\)-]+$/.test(sel); }","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { $(sel).find(childSel); } catch (e) { if (e.message.startsWith('Syntax error, unrecognized expression')) { console.error('Invalid selector:', sel); } else { throw e; } }","preventionTips":["Guard dynamic selector strings for emptiness before use","Escape metacharacters in generated ids with CSS.escape","Validate pseudo-selectors against supported jQuery/Sizzle syntax","Sanitize any user-provided filter expressions"],"tags":["javascript","jquery","sizzle","selector","slim"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}