---
url: /reference/@cssdoc/core/classes/ModifierMatcher.md
---
# Class: ModifierMatcher

Defined in: [packages/core/src/modifier.ts:174](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L174)

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

```ts
new ModifierMatcher(convention): ModifierMatcher;
```

Defined in: [packages/core/src/modifier.ts:191](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L191)

#### Parameters

##### convention

[`ModifierConvention`](../interfaces/ModifierConvention.md)

#### Returns

`ModifierMatcher`

## Properties

### convention

```ts
readonly convention: ModifierConvention;
```

Defined in: [packages/core/src/modifier.ts:175](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L175)

## Methods

### analyze()

```ts
analyze(name): object;
```

Defined in: [packages/core/src/modifier.ts:414](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L414)

Derive `prop`/`value` for a modifier `name` (as returned by [modifiersIn](#modifiersin) or authored).

#### Parameters

##### name

`string`

#### Returns

`object`

##### prop

```ts
prop: string;
```

##### value?

```ts
value?: string;
```

***

### elementsIn()

```ts
elementsIn(selector, baseNoDot): object[];
```

Defined in: [packages/core/src/modifier.ts:316](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L316)

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()

```ts
looksLikeUsage(token, baseNoDot?): boolean;
```

Defined in: [packages/core/src/modifier.ts:471](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L471)

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()

```ts
matchesModifier(name, used): boolean;
```

Defined in: [packages/core/src/modifier.ts:452](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L452)

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()

```ts
modifiersIn(selector, baseNoDot): ModifierHit[];
```

Defined in: [packages/core/src/modifier.ts:237](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L237)

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

[`ModifierHit`](../interfaces/ModifierHit.md)\[]

***

### normalizeMember()

```ts
normalizeMember(token): string;
```

Defined in: [packages/core/src/modifier.ts:459](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L459)

Normalize a member token/expression to its canonical `name` key (the inverse of authoring noise).

#### Parameters

##### token

`string`

#### Returns

`string`

***

### pseudoElementsIn()

```ts
pseudoElementsIn(selector): object[];
```

Defined in: [packages/core/src/modifier.ts:399](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L399)

Every native pseudo-element on the selector recognized for documentation — a `::name` whose `name`
is in the convention's [ModifierConvention.pseudoElements](../interfaces/ModifierConvention.md#pseudoelements) (e.g. `.alert::before` → `before`).
`::part()`/`::slotted()` and pseudo-elements not in the set are ignored.

#### Parameters

##### selector

`string`

#### Returns

`object`\[]

***

### pseudoStatesIn()

```ts
pseudoStatesIn(selector): object[];
```

Defined in: [packages/core/src/modifier.ts:380](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L380)

Every native pseudo-class on the selector recognized as a state — a `:name` whose `name` is in the
convention's [ModifierConvention.statePseudoClasses](../interfaces/ModifierConvention.md#statepseudoclasses) (e.g. `.tab:disabled` → `disabled`).
Pseudo-elements (`::part`) and pseudos not in the set are ignored.

#### Parameters

##### selector

`string`

#### Returns

`object`\[]

***

### selectorFor()

```ts
selectorFor(name): string;
```

Defined in: [packages/core/src/modifier.ts:443](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L443)

Render a modifier `name` as the selector fragment it denotes (`.name` or `[name]`).

#### Parameters

##### name

`string`

#### Returns

`string`

***

### statesIn()

```ts
statesIn(selector, baseNoDot): object[];
```

Defined in: [packages/core/src/modifier.ts:356](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L356)

Every state class chained to `baseNoDot` within one selector — a class whose name starts with one
of the convention's [ModifierConvention.statePrefixes](../interfaces/ModifierConvention.md#stateprefixes) (e.g. `.tabs.is-open` → `is-open`).
Empty when the convention sets no state prefixes.

#### Parameters

##### selector

`string`

##### baseNoDot

`string`

#### Returns

`object`\[]

***

### usageKind()

```ts
usageKind(token, baseNoDot?): "element" | "modifier" | "state" | undefined;
```

Defined in: [packages/core/src/modifier.ts:492](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/modifier.ts#L492)

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`
