From 8007aa8ee7cebb8bf3c1deadc35adb1aad88d507 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 5 Aug 2015 05:00:14 -0700 Subject: [PATCH] automatically find screen if we are using multiple. --- lib/widgets/node.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/widgets/node.js b/lib/widgets/node.js index d3ce283..66046c4 100644 --- a/lib/widgets/node.js +++ b/lib/widgets/node.js @@ -25,10 +25,29 @@ function Node(options) { options = options || {}; this.options = options; + + /* this.screen = this.screen || options.screen + || (options.parent && options.parent.screen) || require('./screen').global || (function(){throw new Error('No active screen.')})(); + */ + + var element; + if (!options.screen && options.parent) { + element = options.parent; + while (element && element.type !== 'screen') { + element = element.parent; + } + } + + this.screen = this.screen + || options.screen + || element + || require('./screen').global + || (function(){throw new Error('No active screen.')})(); + this.parent = options.parent || null; this.children = []; this.$ = this._ = this.data = {};