From eac1ec777213e4aa3314c244c66a590efc4d538a Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Fri, 1 Jul 2016 12:43:41 -0400 Subject: [PATCH] Fix viewTree debug function --- assets/javascripts/debug.js.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/debug.js.coffee b/assets/javascripts/debug.js.coffee index 255293f0..032d93ac 100644 --- a/assets/javascripts/debug.js.coffee +++ b/assets/javascripts/debug.js.coffee @@ -70,13 +70,16 @@ app.Searcher.prototype = _proto # View tree # -@viewTree = (view = app.document, level = 0) -> - console.log "%c #{Array(level + 1).join(' ')}#{view.constructor.name}: #{view.activated}", +@viewTree = (view = app.document, level = 0, visited = []) -> + return if visited.indexOf(view) >= 0 + visited.push(view) + + console.log "%c #{Array(level + 1).join(' ')}#{view.constructor.name}: #{!!view.activated}", 'color:' + (view.activated and 'green' or 'red') - for key, value of view when key isnt 'view' and value + for own key, value of view when key isnt 'view' and value if typeof value is 'object' and value.setupElement - @viewTree(value, level + 1) + @viewTree(value, level + 1, visited) else if value.constructor.toString().match(/Object\(\)/) - @viewTree(v, level + 1) for k, v of value when value and typeof value is 'object' and value.setupElement + @viewTree(v, level + 1, visited) for own k, v of value when v and typeof v is 'object' and v.setupElement return