-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
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) { /* ... */ } ```
/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; } |
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.
isn't it just the same as before but with more letters? )
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.
yep, but it is more obviously
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.
well... I think previous variant was better but still lgtm :)
fix(stringify): should not throw error
Update node-eval to version 1.0.4 🚀
Resolved #55
The stringify method should return
undefined
if impossible tostringify BEM notation.
It will be easier to check for an empty string than use
try..catch
.Before changes:
After changes: