From 00f82aaffe11c6ad2788eadd5cf0a299dd5ea3c7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Jul 2016 10:39:21 -0700 Subject: [PATCH] Only check arrays and objects for cycles --- lib/renderer/api/remote.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index 22326b7842..40f067f340 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -7,18 +7,6 @@ const callbacksRegistry = new CallbacksRegistry() const remoteObjectCache = v8Util.createIDWeakMap() -// Check for circular reference. -const isCircular = function (field, visited) { - if (visited.has(field)) { - return true - } - - if (typeof field === 'object') { - visited.add(field) - } - return false -} - // Convert the arguments object into an array of meta data. const wrapArgs = function (args, visited) { if (visited == null) { @@ -26,7 +14,8 @@ const wrapArgs = function (args, visited) { } const valueToMeta = function (value) { - if (isCircular(value, visited)) { + // Check for circular reference. + if (visited.has(value)) { return { type: 'value', value: null @@ -34,6 +23,7 @@ const wrapArgs = function (args, visited) { } if (Array.isArray(value)) { + visited.add(value) let meta = { type: 'array', value: wrapArgs(value, visited) @@ -70,6 +60,7 @@ const wrapArgs = function (args, visited) { name: value.constructor != null ? value.constructor.name : '', members: [] } + visited.add(value) for (let prop in value) { meta.members.push({ name: prop,