-
Notifications
You must be signed in to change notification settings - Fork 8
/
debug.coffee
47 lines (34 loc) · 1.18 KB
/
debug.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class BaseComponentDebug
@startComponent: (component) ->
name = component.componentName() or 'unnamed'
console.group name
console.log '%o', component
@endComponent: (component) ->
console.groupEnd()
@startMarkedComponent: (component) ->
name = component.componentName() or 'unnamed'
console.group '%c%s', 'text-decoration: underline', name
console.log '%o', component
@endMarkedComponent: (component) ->
@endComponent component
@dumpComponentSubtree: (rootComponent, _markComponent=(->)) ->
return unless rootComponent
marked = _markComponent rootComponent
if marked
@startMarkedComponent rootComponent
else
@startComponent rootComponent
for child in rootComponent.childComponents()
@dumpComponentSubtree child, _markComponent
if marked
@endMarkedComponent rootComponent
else
@endComponent rootComponent
return
@componentRoot: (component) ->
while parentComponent = component.parentComponent()
component = parentComponent
component
@dumpComponentTree: (component) ->
return unless component
@dumpComponentSubtree @componentRoot(component), (c) -> c is component