Skip to content

Commit b4e1266

Browse files
authored
feat: allow null or undefined to modifiers (#41)
This change makes sense for TypeScript users.
1 parent bebee53 commit b4e1266

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
type Modifiers = { [key: string]: boolean; }
2-
31
const defaults = {
42
elementDelimiter: '__',
53
modifierDelimiter: '--',
@@ -32,6 +30,10 @@ export function setup(options: {
3230
}
3331
}
3432

33+
type Modifiers = {
34+
[key: string]: boolean | null | undefined,
35+
}
36+
3537
export default function bem(
3638
block: string,
3739
{

test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ testCases.forEach(({ description, tested, expectations }) => {
119119
it('returns block with modifier', () => {
120120
expect(b({ mod1: true })).toBe(expectations[1])
121121
expect(b({ mod1: true, mod2: false })).toBe(expectations[1])
122+
expect(b({ mod1: true, mod2: null })).toBe(expectations[1])
123+
expect(b({ mod1: true, mod2: undefined })).toBe(expectations[1])
122124
})
123125

124126
it('returns block with multiple modifiers', () => {

0 commit comments

Comments
 (0)