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

fix(stringify): should not throw error #71

Merged
merged 1 commit into from
Mar 20, 2016
Merged

fix(stringify): should not throw error #71

merged 1 commit into from
Mar 20, 2016

Conversation

blond
Copy link
Member

@blond blond commented Mar 20, 2016

Resolved #55

The stringify method should return undefined if impossible to
stringify BEM notation.

It will be easier to check for an empty string than use try..catch.

Before changes:

try {
    var str = bemNaming.stringify({ elem: 'elem' });
} catch(e) { /* ... */ }

After changes:

var str = bemNaming.stringify({ elem: 'elem' });

if (str) {
    /* ... */
}

The stringify method should return `undefined` if impossible to
stringify BEM notation.

It will be easier to check for an empty string than use `try..catch`.

**Before changes:**

```js
try {
    var str = bemNaming.stringify({ elem: 'elem' });
} catch(e) { /* ... */ }
```

**After changes:**

```js
var str = bemNaming.stringify({ elem: 'elem' });

if (str) {
    /* ... */
}
```
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b0cd36c on issue-55 into 87187a4 on master.

@blond
Copy link
Member Author

blond commented Mar 20, 2016

/cc @tadatuta

@@ -68,7 +68,7 @@ BEMNaming.prototype.typeOf = function (obj) {
obj = this.parse(obj);
}

if (!obj || !obj.block) { return; }
if (!obj || !obj.block) { return undefined; }
Copy link
Member

Choose a reason for hiding this comment

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

isn't it just the same as before but with more letters? )

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, but it is more obviously

Copy link
Member

Choose a reason for hiding this comment

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

well... I think previous variant was better but still lgtm :)

blond added a commit that referenced this pull request Mar 20, 2016
fix(stringify): should not throw error
@blond blond merged commit 8cadd87 into master Mar 20, 2016
@blond blond deleted the issue-55 branch March 20, 2016 22:03
qfox added a commit that referenced this pull request Jun 6, 2017
Update node-eval to version 1.0.4 🚀
qfox pushed a commit that referenced this pull request Jun 6, 2017
feat: add belongsTo method
@qfox qfox added the pkg:naming label Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants