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

Commit 22eb626

Browse files
committed
docs: add belongsTo documentation
1 parent b64107f commit 22eb626

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ API
6767
* [type](#type)
6868
* [isSimpleMod()](#issimplemod)
6969
* [isEqual(entityName)](#isequalentityname)
70+
* [belongsTo(entityName)](#belongstoentityname)
7071
* [toString()](#tostring)
7172
* [valueOf()](#valueof)
7273
* [toJSON()](#tojson)
@@ -227,6 +228,29 @@ inputName.isEqual(buttonName); // false
227228
buttonName.isEqual(buttonName); // true
228229
```
229230

231+
### belongsTo(entityName)
232+
233+
Parameter | Type | Description
234+
-------------|-----------------|-----------------------
235+
`entityName` | `BemEntityName` | The entity to compare.
236+
237+
Determines whether specified entity belongs to this.
238+
239+
```js
240+
const BemEntityName = require('@bem/entity-name');
241+
242+
const buttonName = new BemEntityName({ block: 'button' });
243+
const buttonTextName = new BemEntityName({ block: 'button', elem: 'text' });
244+
const buttonTextBoldName = new BemEntityName(
245+
{ block: 'button', elem: 'text', mod: { name: 'bold', val: true } }
246+
);
247+
248+
buttonTextName.belongsTo(buttonName); // true
249+
buttonName.belongsTo(buttonTextName); // false
250+
buttonTextBoldName.belongsTo(buttonTextName); // true
251+
buttonTextBoldName.belongsTo(buttonName); // false
252+
```
253+
230254
### toString()
231255

232256
Returns string representing the entity name.

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,14 @@ class BemEntityName {
318318
*
319319
* const buttonName = new BemEntityName({ block: 'button' });
320320
* const buttonTextName = new BemEntityName({ block: 'button', elem: 'text' });
321+
* const buttonTextBoldName = new BemEntityName(
322+
* { block: 'button', elem: 'text', mod: { name: 'bold', val: true } }
323+
* );
321324
*
322325
* buttonTextName.belongsTo(buttonName); // true
323326
* buttonName.belongsTo(buttonTextName); // false
327+
* buttonTextBoldName.belongsTo(buttonTextName); // true
328+
* buttonTextBoldName.belongsTo(buttonName); // false
324329
*
325330
* @param {BemEntityName} entityName - the entity to compare.
326331
*

0 commit comments

Comments
 (0)