From 2801838ffa0b5a99ccc6c2204397ff84a507f45b Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 21 Apr 2016 22:24:59 +0100 Subject: [PATCH] Throw an error if a Function node adds an input event listener --- nodes/core/core/80-function.js | 3 +++ nodes/core/locales/en-US/messages.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index 5eb96b1bf..224c1f8e2 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -83,6 +83,9 @@ module.exports = function(RED) { sendResults(node, id, msgs); }, on: function() { + if (arguments[0] === "input") { + throw new Error(RED._("function.error.inputListener")); + } node.on.apply(node, arguments); }, status: function() { diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index c8c6bff1d..7d31ec2ab 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -141,6 +141,9 @@ "function": "Function", "outputs": "Outputs" }, + "error": { + "inputListener":"Cannot add listener to 'input' event within Function" + }, "tip": "See the Info tab for help writing functions." }, "template": {