widgets: set root's parent (aka manager) in base class constructor to allow all events from its children to bubble up to the manager while they are parsed
This commit is contained in:
parent
2abba54d59
commit
4af2729faa
2 changed files with 4 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)=>{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue