Skip to content

Commit

Permalink
Merge pull request #1951 from /issues/1950@v3
Browse files Browse the repository at this point in the history
button: Don't render element for text if passed `null` or `undefined`
  • Loading branch information
dfilatov committed Oct 25, 2016
2 parents 60f35ca + 010eb06 commit baf20aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion common.blocks/button/button.bemhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ block('button')(
var ctx = this.ctx,
content = [ctx.icon];
// NOTE: wasn't moved to separate template for optimization
'text' in ctx && content.push({ elem : 'text', content : ctx.text });
/* jshint eqnull: true */
ctx.text != null && content.push({ elem : 'text', content : ctx.text });
return content;
},
match(function() { return typeof this.ctx.content !== 'undefined'; })(function() {
Expand Down
3 changes: 2 additions & 1 deletion common.blocks/button/button.bh.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = function(bh) {
var content = ctx.content();
if(typeof content === 'undefined') {
content = [json.icon];
'text' in json && content.push({ elem : 'text', content : json.text });
/* jshint eqnull: true */
json.text != null && content.push({ elem : 'text', content : json.text });
ctx.content(content);
}
});
Expand Down

0 comments on commit baf20aa

Please sign in to comment.