Skip to content
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

Debuggability methods #10

Merged
merged 2 commits into from
Jan 26, 2017
Merged

Debuggability methods #10

merged 2 commits into from
Jan 26, 2017

Conversation

qfox
Copy link
Contributor

@qfox qfox commented Jan 17, 2017

No description provided.

@@ -129,6 +132,93 @@ const cell = new BemCell({
cell.id; // ➜ "button__text@desktop.css"
```

### toString()

Returns string representing this cell.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns a string


### valueOf()

Returns object representing this cell.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns an object


### toJSON()

Returns object for `JSON.stringify()` purposes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns an object

and not sure about purposes, shouldn't it be in singular?

// ➜ BemCell { entity: { block: 'input', mod: { name: 'available' } }, tech: 'css' }
```

You can also convert `BemCell` object to `string`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to string -> to a string

@qfox
Copy link
Contributor Author

qfox commented Jan 17, 2017

@tadatuta <3 ty

entity: new BemEntityName({ block: 'button', mod: 'focused' })
});

cell.toString(); // button_focused
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше все поля в примере показать, чтобы не путать с BemEntityName.


cell.valueOf();

// ➜ { entity: { block: 'button', mod: { name: 'focused', value: true } } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и тут лучше все поля показать

* In some browsers `console.log()` calls `valueOf()` on each argument.
* This method will be called to get custom string representation of the object.
*
* The representation object contains only `block`, `elem` and `mod` fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужно уточнить, что это про entity поле?

entity: new BemEntityName({ block: 'block' })
});

t.truthy(typeof cell.toString() === 'string');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может ещё проверять, что id равен toString?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А точно есть смысл? Нам же не особо важен формат

*
* @returns {string}
*/
toString() { return this.id; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way why not
path.join(this.layer || '', this.entity) ?

@qfox qfox merged commit 19c172e into master Jan 26, 2017
@qfox qfox deleted the qfox.debuggability branch January 26, 2017 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants