diff --git a/packages/node_modules/@node-red/nodes/core/function/10-function.html b/packages/node_modules/@node-red/nodes/core/function/10-function.html index a57655cf8..624bd3f14 100644 --- a/packages/node_modules/@node-red/nodes/core/function/10-function.html +++ b/packages/node_modules/@node-red/nodes/core/function/10-function.html @@ -312,6 +312,30 @@ } } + + function getLibsList() { + var _libs = []; + if (RED.settings.functionExternalModules === true) { + var libs = $("#node-input-libs-container").editableList("items"); + libs.each(function(i) { + var item = $(this); + var v = item.find(".node-input-libs-var").val(); + var n = item.find(".node-input-libs-val").typedInput("type"); + if (n === "_custom_") { + n = item.find(".node-input-libs-val").val(); + } + if ((!v || (v === "")) || + (!n || (n === ""))) { + return; + } + _libs.push({ + var: v, + module: n + }); + }); + } + return _libs; + } RED.nodes.registerType('function',{ color:"#fdd0a2", @@ -523,28 +547,7 @@ $("#node-input-noerr").val(noerr); this.noerr = noerr; - if (RED.settings.functionExternalModules === true) { - var libs = $("#node-input-libs-container").editableList("items"); - node.libs = []; - libs.each(function(i) { - var item = $(this); - var v = item.find(".node-input-libs-var").val(); - var n = item.find(".node-input-libs-val").typedInput("type"); - if (n === "_custom_") { - n = item.find(".node-input-libs-val").val(); - } - if ((!v || (v === "")) || - (!n || (n === ""))) { - return; - } - node.libs.push({ - var: v, - module: n - }); - }); - } else { - node.libs = []; - } + node.libs = getLibsList(); }, oneditcancel: function() { var node = this;