Add RED.utils.getNodeLabel utility function

This commit is contained in:
Nick O'Leary
2016-11-22 12:57:08 +00:00
parent 0857f979ff
commit b8888a5d46
6 changed files with 26 additions and 76 deletions

View File

@@ -27,19 +27,11 @@ RED.search = (function() {
var results = [];
function indexNode(n) {
var l = "";
if (n._def && n._def.label) {
l = n._def.label;
try {
l = (typeof l === "function" ? l.call(n) : l);
if (l) {
l = (""+l).toLowerCase();
index[l] = index[l] || {};
index[l][n.id] = {node:n,label:l}
}
} catch(err) {
console.log("Definition error: "+n.type+".label",err);
}
var l = RED.utils.getNodeLabel(n);
if (l) {
l = (""+l).toLowerCase();
index[l] = index[l] || {};
index[l][n.id] = {node:n,label:l}
}
l = l||n.label||n.name||n.id||"";