Skip to content
This repository has been archived by the owner on Feb 4, 2018. It is now read-only.

isMod method #53

Closed
blond opened this issue Nov 15, 2016 · 2 comments
Closed

isMod method #53

blond opened this issue Nov 15, 2016 · 2 comments
Assignees
Labels

Comments

@blond
Copy link
Member

blond commented Nov 15, 2016

Similar to entity.type === 'blockMod' || entity.type === 'elemMod'.

In some cases we need to know whether this entity is an modifier or not modifier.

Example:

const text = new BemEntityName({ block: 'button', elem: 'text' });
const focuedButton = new BemEntityName({ block: 'button', mod: 'focused' });

text.isMod() // false
focuedButton.isMod() // true

I don't want to check modifier by mod field. This allows access to mod.name & mod.val fields safe:

const text = new BemEntityName({ block: 'button', elem: 'text' });
const focuedButton = new BemEntityName({ block: 'button', mod: 'focused' });

text.mod.name // undefined
text.mod.val // undefined

focuedButton.mod.name // focused
focuedButton.mod.val // true
@blond blond added the question label Nov 15, 2016
@blond
Copy link
Member Author

blond commented Nov 15, 2016

If not add isMod method we should change mod field for non-modifiers.

Example:

const text = new BemEntityName({ block: 'button', elem: 'text' });
const focuedButton = new BemEntityName({ block: 'button', mod: 'focused' });

text.mod // undefined

focuedButton.mod.name // focused
focuedButton.mod.val // true

Boolean(text.mod); // false
Boolean(focuedButton.mod); // true

@qfox
Copy link
Contributor

qfox commented Nov 15, 2016

Guess changing is fine here since we normalizing data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants