« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui/DisplayElement.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/ui/DisplayElement.js b/ui/DisplayElement.js
index ca50672..1ba9852 100644
--- a/ui/DisplayElement.js
+++ b/ui/DisplayElement.js
@@ -77,7 +77,7 @@ module.exports = class DisplayElement extends EventEmitter {
     }
   }
 
-  addChild(child) {
+  addChild(child, afterIndex = this.children.length) {
     // TODO Don't let a direct ancestor of this be added as a child. Don't
     // let itself be one of its childs either!
 
@@ -87,7 +87,7 @@ module.exports = class DisplayElement extends EventEmitter {
     }
 
     child.parent = this
-    this.children.push(child)
+    this.children.splice(afterIndex, 0, child)
     child.fixLayout()
   }