automatically find screen if we are using multiple.

This commit is contained in:
Christopher Jeffrey 2015-08-05 05:00:14 -07:00
parent a9fb228f23
commit 8007aa8ee7
1 changed files with 19 additions and 0 deletions

View File

@ -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 = {};