From 483306e73c224477a20f7f756a6c98fc33e28db6 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 19 May 2017 20:35:36 +0100 Subject: [PATCH] Avoid circular references when stingifying node objects --- editor/js/ui/view.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index 926503639..9ceaf8d1d 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -1165,7 +1165,14 @@ RED.view = (function() { } } - var selectionJSON = JSON.stringify(selection); + var selectionJSON = JSON.stringify(selection,function(key,value) { + if (key === 'nodes') { + return value.map(function(n) { return n.id }) + } else if (key === 'link') { + return value.source.id+":"+value.sourcePort+":"+value.target.id; + } + return value; + }); if (selectionJSON !== lastSelection) { lastSelection = selectionJSON; RED.events.emit("view:selection-changed",selection);