diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js b/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js index 8ebc97cda..c7c5dd950 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/actions.js @@ -4,6 +4,12 @@ RED.actions = (function() { } function addAction(name,handler) { + if (typeof handler !== 'function') { + throw new Error("Action handler not a function"); + } + if (actions[name]) { + throw new Error("Cannot override existing action"); + } actions[name] = handler; } function removeAction(name) { @@ -12,9 +18,11 @@ RED.actions = (function() { function getAction(name) { return actions[name]; } - function invokeAction(name,args) { + function invokeAction() { + var args = Array.prototype.slice.call(arguments); + var name = args.shift(); if (actions.hasOwnProperty(name)) { - actions[name](args); + actions[name].apply(null, args); } } function listActions() {