File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ export type Preset = {
4949 v ?: string
5050}
5151
52+ function isEmpty ( val : string | boolean | number | undefined ) {
53+ return ! val && val !== 0
54+ }
55+
5256/**
5357 * BEM className configure function.
5458 *
@@ -81,7 +85,7 @@ export function withNaming(preset: Preset): ClassNameInitilizer {
8185
8286 if ( modVal === true ) {
8387 className += modPrefix + k
84- } else if ( modVal ) {
88+ } else if ( ! isEmpty ( modVal ) ) {
8589 className += modPrefix + k + modValueDelimiter + modVal
8690 }
8791 }
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ describe('@bem-react/classname', () => {
4949
5050 test ( 'zero' , ( ) => {
5151 const b = cn ( 'Block' )
52- expect ( b ( { modName : '0' } ) ) . toEqual ( 'Block Block_modName_0' )
52+ expect ( b ( { modName : '0' , mod : 0 } ) ) . toEqual ( 'Block Block_modName_0 Block_mod_0 ' )
5353 } )
5454
5555 test ( 'undefined' , ( ) => {
@@ -211,7 +211,7 @@ describe('@bem-react/classname', () => {
211211
212212 test ( 'zero' , ( ) => {
213213 const b = cCn ( 'block' )
214- expect ( b ( { modName : '0' } ) ) . toEqual ( 'block block_modName_0' )
214+ expect ( b ( { modName : '0' , mod : 0 } ) ) . toEqual ( 'block block_modName_0 block_mod_0 ' )
215215 } )
216216 } )
217217 } )
You can’t perform that action at this time.
0 commit comments