Class: ModifierMatcher
Defined in: packages/core/src/modifier.ts:174
The single owner of modifier recognition for one convention: finds modifiers on selectors, derives prop/value, renders a modifier name back to a selector fragment, and answers "does this host-doc token look like a modifier usage?". Constructed once per parse from the resolved convention.
Constructors
Constructor
new ModifierMatcher(convention): ModifierMatcher;Defined in: packages/core/src/modifier.ts:191
Parameters
convention
Returns
ModifierMatcher
Properties
convention
readonly convention: ModifierConvention;Defined in: packages/core/src/modifier.ts:175
Methods
analyze()
analyze(name): object;Defined in: packages/core/src/modifier.ts:413
Derive prop/value for a modifier name (as returned by modifiersIn or authored).
Parameters
name
string
Returns
object
prop
prop: string;value?
optional value?: string;elementsIn()
elementsIn(selector, baseNoDot): object[];Defined in: packages/core/src/modifier.ts:315
Every BEM-style element attached to baseNoDot within one selector (.base<elementSep><name>), as parts, each with any element-scoped modifiers (.base__element--mod → element base__element with modifier mod). Only meaningful for suffix conventions with an elementSeparator.
Parameters
selector
string
baseNoDot
string
Returns
object[]
looksLikeUsage()
looksLikeUsage(token, baseNoDot?): boolean;Defined in: packages/core/src/modifier.ts:470
Does a token/expression seen in a host document (an HTML class token, or an attribute expression) look like a modifier usage of baseNoDot? Replaces the old startsWith("-") gate.
Parameters
token
string
baseNoDot?
string
Returns
boolean
matchesModifier()
matchesModifier(name, used): boolean;Defined in: packages/core/src/modifier.ts:451
Whether a used class used is an instance of the documented modifier name — an exact match, or, when name is a * family (e.g. -icon-*), a glob match (* → any [\w-] run). Used consumer-side so -icon-arrow resolves to the documented -icon-* family.
Parameters
name
string
used
string
Returns
boolean
modifiersIn()
modifiersIn(selector, baseNoDot): ModifierHit[];Defined in: packages/core/src/modifier.ts:236
Every modifier attached to baseNoDot within one selector. selector should have its pseudos already dropped (as parse.ts/index.ts do); the base is given without its leading dot.
Parameters
selector
string
baseNoDot
string
Returns
normalizeMember()
normalizeMember(token): string;Defined in: packages/core/src/modifier.ts:458
Normalize a member token/expression to its canonical name key (the inverse of authoring noise).
Parameters
token
string
Returns
string
pseudoElementsIn()
pseudoElementsIn(selector): object[];Defined in: packages/core/src/modifier.ts:398
Every native pseudo-element on the selector recognized for documentation — a ::name whose name is in the convention's ModifierConvention.pseudoElements (e.g. .alert::before → before). ::part()/::slotted() and pseudo-elements not in the set are ignored.
Parameters
selector
string
Returns
object[]
pseudoStatesIn()
pseudoStatesIn(selector): object[];Defined in: packages/core/src/modifier.ts:379
Every native pseudo-class on the selector recognized as a state — a :name whose name is in the convention's ModifierConvention.statePseudoClasses (e.g. .tab:disabled → disabled). Pseudo-elements (::part) and pseudos not in the set are ignored.
Parameters
selector
string
Returns
object[]
selectorFor()
selectorFor(name): string;Defined in: packages/core/src/modifier.ts:442
Render a modifier name as the selector fragment it denotes (.name or [name]).
Parameters
name
string
Returns
string
statesIn()
statesIn(selector, baseNoDot): object[];Defined in: packages/core/src/modifier.ts:355
Every state class chained to baseNoDot within one selector — a class whose name starts with one of the convention's ModifierConvention.statePrefixes (e.g. .tabs.is-open → is-open). Empty when the convention sets no state prefixes.
Parameters
selector
string
baseNoDot
string
Returns
object[]
usageKind()
usageKind(token, baseNoDot?): "element" | "modifier" | "state" | undefined;Defined in: packages/core/src/modifier.ts:491
Classify a host-document class token relative to baseNoDot: a modifier usage, a state class (a statePrefixes prefix), a BEM element class (base<elementSep>…), or undefined if it's none of those. Consumer-side linting routes each kind to the right "unknown-…" check.
Parameters
token
string
baseNoDot?
string
Returns
"element" | "modifier" | "state" | undefined