Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcLear authored and muxator committed Mar 14, 2020
1 parent bb868be commit 467fc11
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/node/utils/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ButtonsGroup.prototype.addButton = function (button) {
};

ButtonsGroup.prototype.render = function () {
if (this.buttons.length == 1) {
if (this.buttons && this.buttons.length == 1) {
this.buttons[0].grouping = "";
}
else {
Expand All @@ -80,7 +80,7 @@ ButtonsGroup.prototype.render = function () {
}

return _.map(this.buttons, function (btn) {
return btn.render();
if(btn) return btn.render();
}).join("\n");
};

Expand All @@ -90,11 +90,16 @@ Button = function (attributes) {

Button.load = function (btnName) {
var button = module.exports.availableButtons[btnName];
if (button.constructor === Button || button.constructor === SelectButton) {
return button;
}
else {
return new Button(button);
try{
if (button.constructor === Button || button.constructor === SelectButton) {
return button;
}
else {
return new Button(button);
}
}catch(e){
console.warn("Error loading button", btnName);
return false;
}
};

Expand Down

0 comments on commit 467fc11

Please sign in to comment.