From 1c94064c577897ad58bbc287d166a4b2246ca683 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 22 May 2020 20:54:06 +0100 Subject: [PATCH] Remove unused _info/_type subflow env var magic values --- .../runtime/lib/nodes/flows/Subflow.js | 49 ++----------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js index e34667ffd..cca230d79 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js @@ -47,38 +47,6 @@ function evaluateInputValue(value, type, node) { return redUtil.evaluateNodeProperty(value, type, node, null, null); } -/** - * Compose information object for env var - */ -function composeInfo(info, val) { - var result = { - name: info.name, - type: info.type, - value: val, - }; - if (info.ui) { - var ui = info.ui; - result.ui = { - hasUI: ui.hasUI, - icon: ui.icon, - labels: ui.labels, - type: ui.type - }; - var retUI = result.ui; - if (ui.type === "input") { - retUI.inputTypes = ui.inputTypes; - } - if (ui.type === "select") { - retUI.menu = ui.menu; - } - if (ui.type === "spinner") { - retUI.spinner = ui.spinner; - } - } - return result; -} - - /** * This class represents a subflow - which is handled as a special type of Flow */ @@ -349,15 +317,8 @@ class Subflow extends Flow { getSetting(name) { if (!/^\$parent\./.test(name)) { var env = this.env; - var is_info = name.endsWith("_info"); - var is_type = name.endsWith("_type"); - var ename = (is_info || is_type) ? name.substring(0, name.length -5) : name; // 5 = length of "_info"/"_type" - - if (env && env.hasOwnProperty(ename)) { - var val = env[ename]; - if (is_type) { - return val ? val.type : undefined; - } + if (env && env.hasOwnProperty(name)) { + var val = env[name]; // If this is an env type property we need to be careful not // to get into lookup loops. // 1. if the value to lookup is the same as this one, go straight to parent @@ -371,11 +332,7 @@ class Subflow extends Flow { value = value.replace(new RegExp("\\${"+name+"}","g"),"${$parent."+name+"}"); } try { - var ret = evaluateInputValue(value, type, this.node); - if (is_info) { - return composeInfo(val, ret); - } - return ret; + return evaluateInputValue(value, type, this.node); } catch (e) { this.error(e);