From 39d8386e43eaf38c6c025d4a4acd4d57cc9affab Mon Sep 17 00:00:00 2001 From: GogoVega <92022724+GogoVega@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:33:00 +0200 Subject: [PATCH] Fix bad use of `hasOwnProperty` on an Array --- .../@node-red/editor-client/src/js/nodes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index e6053b887..2bdfe3d2d 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -2142,7 +2142,7 @@ RED.nodes = (function() { nodeZmap[recoveryWorkspace.id] = []; } node.z = recoveryWorkspace.id; - nodeZmap[recoveryWorkspace.id].push(node); + nodeZmap[node.z].push(node); } } @@ -2385,14 +2385,14 @@ RED.nodes = (function() { }); const newLinks = []; - // Remap all wires and (Config) Node references + // Remap all Wires and (Config) Node references for (const node of [...newNodes, ...newGroups]) { if (node.wires) { for (const wiresGroup of node.wires) { const wires = Array.isArray(wiresGroup) ? wiresGroup : [wiresGroup]; wires.forEach(function (wire) { // Skip if the wire is clinked to a non-existent node - // TODO: Add warning message? Add RED.nodes.node() for same workspace? + // TODO: Add warning message? if (!nodeMap.hasOwnProperty(wire)) { return; } if (node.z === nodeMap[wire].z) { const link = { source: node, sourcePort: node.wires.indexOf(wiresGroup), target: nodeMap[wire] }; @@ -2521,14 +2521,14 @@ RED.nodes = (function() { }); for (const index in newGroups) { - if (newGroups.hasOwnProperty(newGroups[index])) { + if (newGroups.indexOf(newGroups[index]) !== -1) { newGroups[index] = addGroup(newGroups[index]); nodeMap[newGroups[index].id] = newGroups[index]; } } for (const index in newJunctions) { - if (newJunctions.hasOwnProperty(newJunctions[index])) { + if (newJunctions.indexOf(newJunctions[index]) !== -1) { newJunctions[index] = addJunction(newJunctions[index]); nodeMap[newJunctions[index].id] = newJunctions[index]; } @@ -2536,7 +2536,7 @@ RED.nodes = (function() { // Now the nodes have been fully updated, add them as Proxy. for (const index in newNodes) { - if (newNodes.hasOwnProperty(newNodes[index])) { + if (newNodes.indexOf(newNodes[index]) !== -1) { newNodes[index] = addNode(newNodes[index]); nodeMap[newNodes[index].id] = newNodes[index]; }