css-selector-parser / Exports / SyntaxDefinition
CSS Selector Syntax Definition can be used to define custom CSS selector parsing rules.
- attributes
- baseSyntax
- classNames
- combinators
- ids
- modules
- namespace
- nestingSelector
- pseudoClasses
- pseudoElements
- tag
• Optional attributes: false | { caseSensitivityModifiers?: string[] ; operators?: string[] ; unknownCaseSensitivityModifiers?: "accept" | "reject" }
CSS Attribute Selector.
Example
[href="#"]See
https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Attribute_selectors
• Optional baseSyntax: CssLevel
When specified, syntax will be based on the specified predefined CSS standard. If not specified, syntax will be defined from scratch.
• Optional classNames: boolean
CSS Class Names
Example
.element.highlightedSee
• Optional combinators: string[]
CSS selector rule nesting combinators.
Example
div.class > spanSee
https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators
• Optional ids: boolean
CSS IDs (yes, there can be multiple).
Example
#root#rootSee
• Optional modules: ("css-position-1" | "css-position-2" | "css-position-3" | "css-position-4" | "css-scoping-1" | "css-pseudo-4" | "css-shadow-parts-1" | "css-nesting-1")[]
Additional CSS modules to include in the syntax definition. These are specific CSS modules that add new selectors or modify existing ones.
Example
['css-position-4', 'css-scoping-1']• Optional namespace: boolean | { wildcard?: boolean }
CSS3 Namespaces.
Example
ns|divSee
https://www.w3.org/TR/css3-namespace/
• Optional nestingSelector: boolean
CSS Nesting Selector (&). Represents the parent selector in nested CSS.
Example
&:hoverSee
https://www.w3.org/TR/css-nesting-1/#nest-selector
• Optional pseudoClasses: false | { definitions?: { Formula: undefined | string[] ; FormulaOfSelector: undefined | string[] ; NoArgument: undefined | string[] ; Selector: undefined | string[] ; String: undefined | string[] } ; unknown?: "accept" | "reject" }
CSS Pseudo-classes.
Example
:nth-child(2n+1)See
• Optional pseudoElements: false | { definitions?: string[] | { NoArgument: undefined | string[] ; Selector: undefined | string[] ; String: undefined | string[] } ; notation?: "both" | "singleColon" | "doubleColon" ; unknown?: "accept" | "reject" }
CSS Pseudo-elements.
Example
::beforeSee
• Optional tag: boolean | { wildcard?: boolean }
CSS Tag (type).
Example
divSee