-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BemCell.create method #13
Conversation
907ae01
to
27a9014
Compare
@@ -191,6 +192,40 @@ BemCell.isBemCell(cell); // true | |||
BemCell.isBemCell({}); // false | |||
``` | |||
|
|||
### #create(object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а что означает # перед названием?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Статический метод. Можно как-то иначе их обозначать, это такое.
README.md
Outdated
|
||
Creates BemCell instance by the any object representation. | ||
|
||
Helper for laziness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
)))
Может тогда lazybones?
test/create.test.js
Outdated
}); | ||
|
||
test('should create BemCell for block from obj', t => { | ||
const data = { block: 'b', elem: 'e' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем тут элемент? Да и кажется переменная не требуется (как в тесте ниже)
}); | ||
|
||
test('should create cell with tech', t => { | ||
const cell = BemCell.create({ block: 'block', tech: 'css' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо еще добавить тест про BemCell.create({ entity, tech, layer })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
27a9014
to
dadc777
Compare
README.md
Outdated
@@ -191,6 +192,40 @@ BemCell.isBemCell(cell); // true | |||
BemCell.isBemCell({}); // false | |||
``` | |||
|
|||
### #create(object) | |||
|
|||
Creates BemCell instance by the any object representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the
index.js
Outdated
@@ -211,4 +211,42 @@ module.exports = class BemCell { | |||
static isBemCell(cell) { | |||
return cell && this.name === cell.constructor.name; | |||
} | |||
|
|||
/** | |||
* Creates BemCell instance by the any object representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
* @param {string} obj.block — the block name of entity. | ||
* @param {string} [obj.elem] — the element name of entity. | ||
* @param {object|string} [obj.mod] — the modifier of entity. | ||
* @param {string} obj.mod.name — the modifier name of entity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it's not if obj.mod is an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ок
index.js
Outdated
* // BemCell { block: 'my-button', mod: { name: 'theme', val: 'red' }, tech: 'css' } | ||
*/ | ||
static create(obj) { | ||
if (BemCell.isBemCell(obj)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what s the purpose ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent creating BemCells from BemCells
dadc777
to
63dafcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
63dafcd
to
620e74d
Compare
620e74d
to
65e4cde
Compare
cc @Yeti-or @blond @tadatuta
Blocked by bem-sdk-archive/bem-entity-name#72
Closes #12