History

Fix viewTree debug function

Thibaut Courouble committed 10 years ago

Commit eac1ec71 parent 0970a441 file · +8 −5Browse files

Unified · Split

assets/javascripts/debug.js.coffee+8−5
@@ -70,13 +70,16 @@ app.Searcher.prototype = _proto · 69 unmodified lines
7070 # View tree
7171 #
7272
73−@viewTree = (view = app.document, level = 0) ->
74− console.log "%c #{Array(level + 1).join(' ')}#{view.constructor.name}: #{view.activated}",
73+@viewTree = (view = app.document, level = 0, visited = []) ->
74+ return if visited.indexOf(view) >= 0
75+ visited.push(view)
76+
77+ console.log "%c #{Array(level + 1).join(' ')}#{view.constructor.name}: #{!!view.activated}",
7578 'color:' + (view.activated and 'green' or 'red')
7679
77− for key, value of view when key isnt 'view' and value
80+ for own key, value of view when key isnt 'view' and value
7881 if typeof value is 'object' and value.setupElement
79− @viewTree(value, level + 1)
82+ @viewTree(value, level + 1, visited)
8083 else if value.constructor.toString().match(/Object\(\)/)
81− @viewTree(v, level + 1) for k, v of value when value and typeof value is 'object' and value.setupElement
84+ @viewTree(v, level + 1, visited) for own k, v of value when v and typeof v is 'object' and v.setupElement
8285 return

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t