From 2bbdc85a295514819370514578d14472339576ae Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 13 May 2021 14:28:01 +0100 Subject: [PATCH] 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 --- .../node_modules/@node-red/editor-client/src/js/ui/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js index bb17ea395..9a8f0baa5 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js @@ -875,6 +875,7 @@ RED.utils = (function() { } function getDefaultNodeIcon(def,node) { + def = def || {}; var icon_url; if (node && node.type === "subflow") { icon_url = "node-red/subflow.svg"; @@ -912,6 +913,7 @@ RED.utils = (function() { } function getNodeIcon(def,node) { + def = def || {}; if (node && node.type === '_selection_') { return "font-awesome/fa-object-ungroup"; } else if (node && node.type === 'group') { @@ -999,6 +1001,7 @@ RED.utils = (function() { } function getNodeColor(type, def) { + def = def || {}; var result = def.color; var paletteTheme = RED.settings.theme('palette.theme') || []; if (paletteTheme.length > 0) {