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

Commit f0297e8

Browse files
author
blond
committed
docs(mod): should return undefined if entity is not modifier
1 parent 9909d1c commit f0297e8

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const entityName = new BemEntityName({ block: 'button', elem: 'text' });
3737

3838
entityName.block; // button
3939
entityName.elem; // text
40-
entityName.mod; // {}
40+
entityName.mod; // undefined
4141

4242
entityName.id; // button__elem
4343
entityName.type; // elem
@@ -143,13 +143,16 @@ name.elem; // text
143143

144144
The modifier of this entity.
145145

146-
If entity is not modifier then returns empty object.
146+
**Important:** If entity is not a modifier then returns `undefined`.
147147

148148
```js
149149
const BemEntityName = require('bem-entity-name');
150-
const name = new BemEntityName({ block: 'button', mod: 'disabled' });
151150

152-
name.mod; // { name: 'disabled', val: true }
151+
const blockName = new BemEntityName({ block: 'button' });
152+
const modName = new BemEntityName({ block: 'button', mod: 'disabled' });
153+
154+
modName.mod; // { name: 'disabled', val: true }
155+
blockName.mod; // undefined
153156
```
154157

155158
### id

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ module.exports = class BemEntityName {
7676
/**
7777
* Returns the modifier of this entity.
7878
*
79-
* If entity is not modifier then returns empty object.
79+
* Important: If entity is not a modifier then returns `undefined`.
8080
*
8181
* @example
8282
* const BemEntityName = require('bem-entity-name');
83-
* const name = new BemEntityName({ block: 'button', mod: 'disabled' });
8483
*
85-
* console.log(name.mod); // { name: 'disabled', val: true }
84+
* const blockName = new BemEntityName({ block: 'button' });
85+
* const modName = new BemEntityName({ block: 'button', mod: 'disabled' });
86+
*
87+
* console.log(modName.mod); // { name: 'disabled', val: true }
88+
* console.log(blockName.mod); // undefined
8689
*
8790
* @returns {{mod: string, val: *}} entity modifier.
8891
*/

0 commit comments

Comments
 (0)