diff --git a/src/browser/js/app/widgets/common/_widgets_base.js b/src/browser/js/app/widgets/common/_widgets_base.js index 0ffb28c9..1852aa2e 100644 --- a/src/browser/js/app/widgets/common/_widgets_base.js +++ b/src/browser/js/app/widgets/common/_widgets_base.js @@ -31,7 +31,7 @@ module.exports = class _widgets_base extends EventEmitter { this.container = options.container || fallbackContainer this.widget = DOM.create(options.html) this.props = options.props - this.parent = options.parent + this.parent = options.root ? widgetManager : options.parent this.parentNode = options.parentNode this.hash = _widgets_base.createHash() this.childrenHashes = [] @@ -101,6 +101,8 @@ module.exports = class _widgets_base extends EventEmitter { this.precision = Math.min(20,Math.max(this.getProp('precision', undefined, false),0)) } + if (this.getProp('id') == 'root' && !options.root) throw new Error('There can only be one root') + this.on('widget-created', (e)=>{ if (e.widget == this) return diff --git a/src/browser/js/app/widgets/containers/root.js b/src/browser/js/app/widgets/containers/root.js index b4616f59..cf7531c0 100644 --- a/src/browser/js/app/widgets/containers/root.js +++ b/src/browser/js/app/widgets/containers/root.js @@ -40,13 +40,13 @@ module.exports = class Root extends Panel { constructor(options) { + options.root = true options.props.id = 'root' options.props.scroll = true options.props.label = false super(options) - this.parent = widgetManager this.widget.classList.add('root') DOM.each(this.widget, '> .navigation', (el)=>{