lazily load Screen in helpers.js. fixes #164.

This commit is contained in:
Christopher Jeffrey 2015-08-05 17:59:18 -07:00
parent 54430504d1
commit e6a5b0cac9
1 changed files with 9 additions and 2 deletions

View File

@ -93,9 +93,9 @@ helpers.escape = function(text) {
});
};
helpers.parseTags = function(text) {
helpers.parseTags = function(text, screen) {
return helpers.Element.prototype._parseTags.call(
{ parseTags: true, screen: Screen.global }, text);
{ parseTags: true, screen: screen || helpers.Screen.global }, text);
};
helpers.generateTags = function(style, text) {
@ -150,6 +150,13 @@ helpers.dropUnicode = function(text) {
.replace(unicode.chars.surrogate, '?');
};
helpers.__defineGetter__('Screen', function() {
if (!helpers._screen) {
helpers._screen = require('./widgets/screen');
}
return helpers._screen;
});
helpers.__defineGetter__('Element', function() {
if (!helpers._element) {
helpers._element = require('./widgets/element');