diff --git a/elements/tree-view.html b/elements/tree-view.html
index 48e5bed..51e8a65 100644
--- a/elements/tree-view.html
+++ b/elements/tree-view.html
@@ -14,6 +14,11 @@
@@ -81,17 +117,21 @@
ready() {
super.ready();
- this.$.tree.addEventListener('click', this.findElement.bind(this))
+ this.$.tree.addEventListener('click', this.findElement.bind(this));
}
recomputeTree(parent, active) {
this.$.tree.innerHTML = '';
+ let ul = document.createElement('ul');
+ ul.classList.add('tree');
+ this.$.tree.appendChild(ul);
+
// Since we can't add a pojo to each button, generate a new index for
// each button in the this.items array of useful data.
+
this._index = 0;
- this.items = this.getChildren(parent, this.$.tree);
+ this.items = this.getChildren(parent, ul);
this.highlight(active);
- this.$.tree
return this.items;
}
@@ -109,40 +149,44 @@
return aButton;
}
- getChildren(parent, div) {
- // At every new parent, we create a new
- let ul = document.createElement('ul');
- div.appendChild(ul);
+ getChildren(item, list) {
+ // Add item and its children into nested ul list
- let isViewContainer = parent.id === 'viewContainer';
+ let isViewContainer = item.id === 'viewContainer';
let data = {
- tag: isViewContainer ? 'main-app': parent.tagName.toLowerCase(),
- id: isViewContainer ? '' : (parent.id ? '#' + parent.id : ''),
- text: isViewContainer ? '' : '"' + parent.textContent + '"',
- ref: parent,
+ tag: isViewContainer ? 'main-app': item.tagName.toLowerCase(),
+ id: isViewContainer ? '' : (item.id ? '#' + item.id : ''),
+ text: isViewContainer ? '' : '"' + item.textContent + '"',
+ ref: item,
index: this._index
};
- // Create this node's content;
+ // Add item to list
let li = document.createElement('li');
let button = this._makeButton(data.tag, data.id, data.index);
li.appendChild(button);
- ul.appendChild(li);
+ list.appendChild(li);
this._index++;
let nodes = [data];
- // If this node has children...
- for (let i = 0; i < parent.children.length; i++) {
- let child = parent.children[i];
+ // Add children to subordinate list
+ let ul = null;
+ for (let i = 0; i < item.children.length; i++) {
+ let child = item.children[i];
+
// Skip