bem-sdk-archive / bem-entity-name

BEM entity name representation. DEPRECATED →
https://github.com/bem/bem-sdk/tree/master/packages/entity-name
Other
5 stars 3 forks source link

Turn off modifier #42

Closed blond closed 7 years ago

blond commented 8 years ago

Now bem-naming turn off modifier if modifier value is falsy.

Actual BemEntityName:

const entityName = new BemEntityName({ block: 'block', mod: { name: 'mod', val: false } });

entity.mod // { name: 'mod', val: null }
entity.type // mod

bem-naming expected:

const entityName = new BemEntityName({ block: 'block', mod: { name: 'mod', val: false } });

entity.mod // {}
entity.type // block
blond commented 8 years ago

@tadatuta @zxqfox what do you think?

Is it necessary to repeat the same behavior?

qfox commented 8 years ago

I'm not sure what these two record means:

{ block: 'block', mod: { name: 'mod', val: false } }
{ block: 'block', mod: {} })

At the moment we need 3 states: some specific modifier, any modifier, and no modifier:

{ mod: 'm', val: 'v' }
{ mod: 'm', val: true } or { mod: 'm' }
{ }

val: false is more than we need at my pov. What is the purpose of that?

blond commented 8 years ago

{ block: 'block', mod: {} })

It is mean { block: 'block' }.

{ block: 'block', mod: { name: 'mod', val: false } }

In bem-naming it is mean { block: 'block' }.

Now in bem-entity-name it is mean { block: 'block', mod: { name: 'mod', val: false } }.

qfox commented 7 years ago

Now in bem-entity-name it is mean { block: 'block', mod: { name: 'mod', val: false } }.

What the heck is that?

blond commented 7 years ago

What the heck is that?

Modifier with false value.

blond commented 7 years ago

We decided not to change the normalize logic. If necessary, this can be done in higher-level packages.

qfox commented 7 years ago

Actual:

> q = new BemEntityName({ block: 'block', mod: { name: 'mod', val: false } });
BemEntityName { block: 'block', mod: { name: 'mod', val: undefined } }
> q.mod
{ name: 'mod', val: undefined }
> q.id
'block_mod'
>
qfox commented 7 years ago

We decided to assert modifier value: it should be nothing, or a string, or boolean true value.

blond commented 7 years ago

Closed in favor of #80