BREAKING: simplify construct and add create method#70
Conversation
| * @param {string} [obj.mod.name] — the modifier name of entity. | ||
| * @param {string} [obj.mod.val] — the modifier value of entity. | ||
| * @param {string} obj.mod.name — the modifier name of entity. | ||
| * @param {string} obj.mod.val — the modifier value of entity. |
There was a problem hiding this comment.
Почему стали обязательными полями?
There was a problem hiding this comment.
Если mod передан, то name обязателен. val всё еще нет. Косяк
| t.is(entity.mod.name, 'mod1'); | ||
| }); | ||
|
|
||
| test('should use `mod.val` field instead of `modVal`', t => { |
There was a problem hiding this comment.
Можно ещё тестов:
mod: { name, val }+modVal+val- и
mod: { name, val }+val
| * @example | ||
| * const BemEntityName = require('@bem/entity-name'); | ||
| * | ||
| * BemEntityName.create('my-button_theme_red'); |
There was a problem hiding this comment.
рядом надо писать ахтунг-комментарий, что это id, а не naming
There was a problem hiding this comment.
Supported only strings generated with id property. Написал в описание параметра
|
Досыпал документации |
blond
left a comment
There was a problem hiding this comment.
мелкие замечания по документации
| **Example:** | ||
|
|
||
| ```js | ||
| // Boolean modifier of a block |
|
|
||
| Returns object for `JSON.stringify()` purposes. | ||
|
|
||
| ### #isBemEntityName(entityName) |
|
|
||
| Helper for laziness. | ||
|
|
||
| **Important:** Only generated by id property strings are allowed. |
There was a problem hiding this comment.
Чот ощущуние, что можно передать только строку.
| BemEntityName.create('my-button_theme_red'); | ||
| BemEntityName.create({ block: 'my-button', mod: 'theme', val: 'red' }); | ||
| BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' }); | ||
| // BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } } |
There was a problem hiding this comment.
давай со стрелкой:
// ➜ BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } }
f36fe69 to
f52528a
Compare
|
|
||
| To describe the simple modifier, field `mod.val` must be specified as `true`. | ||
|
|
||
| To describe the simple modifier field `mod.val` must be specified as `true`. |
There was a problem hiding this comment.
Do you think that people do not understand at first time? =)
| const entityName = new BemEntityName({ block: 'input' }); | ||
|
|
||
| BemEntityName.isBemEntityName(entityName); // true | ||
| BemEntityName.isBemEntityName({}); // false |
| `mod.name` | `string` | The modifier name of entity. | ||
| `mod.val` | `*` | The modifier value of entity. | ||
| `modName` | `string` | The modifier name of entity. | ||
| `modVal` | `*` | The modifier value of entity. |
There was a problem hiding this comment.
modVal can be only String|True|undefined
| * @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. |
| * BemEntityName.create('my-button_theme_red'); | ||
| * BemEntityName.create({ block: 'my-button', mod: 'theme', val: 'red' }); | ||
| * BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' }); | ||
| * // BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } } |
| if (mod || obj.modName) { | ||
| const isString = typeof mod === 'string'; | ||
| const modName = (isString ? mod : mod && mod.name) || obj.modName; | ||
| const modObj = !isString && mod || obj; |
There was a problem hiding this comment.
Why is initial obj? There is no description about it. I think empty Object is better here.
f52528a to
7d116b2
Compare
cc @tadatuta @blond @Yeti-or