Prevent unknown node from breaking editor

If a node provides a .js file that registers a type
but its .html is empty, then the editor will know about
the type, but there will be no node definition.

This fix handles that in some of the utility functions
for generating node appearance.

This wasn't an exhaustive check for these things - just
some obvious candidates that I hit in testing 'bad' nodes
This commit is contained in:
Nick O'Leary
2021-05-13 14:28:01 +01:00
parent 15aa249f64
commit 2bbdc85a29

View File

@@ -875,6 +875,7 @@ RED.utils = (function() {
} }
function getDefaultNodeIcon(def,node) { function getDefaultNodeIcon(def,node) {
def = def || {};
var icon_url; var icon_url;
if (node && node.type === "subflow") { if (node && node.type === "subflow") {
icon_url = "node-red/subflow.svg"; icon_url = "node-red/subflow.svg";
@@ -912,6 +913,7 @@ RED.utils = (function() {
} }
function getNodeIcon(def,node) { function getNodeIcon(def,node) {
def = def || {};
if (node && node.type === '_selection_') { if (node && node.type === '_selection_') {
return "font-awesome/fa-object-ungroup"; return "font-awesome/fa-object-ungroup";
} else if (node && node.type === 'group') { } else if (node && node.type === 'group') {
@@ -999,6 +1001,7 @@ RED.utils = (function() {
} }
function getNodeColor(type, def) { function getNodeColor(type, def) {
def = def || {};
var result = def.color; var result = def.color;
var paletteTheme = RED.settings.theme('palette.theme') || []; var paletteTheme = RED.settings.theme('palette.theme') || [];
if (paletteTheme.length > 0) { if (paletteTheme.length > 0) {