widgets: prevent update errors when widgets are not fully initialized (add widget.mounted property)

This commit is contained in:
bordun 2019-11-05 19:43:15 +01:00
parent e93464828f
commit 7e1ed9a2cf
5 changed files with 14 additions and 0 deletions

View file

@ -36,6 +36,11 @@ function updateWidget(widget, options={}) {
}
if (!widget.mounted) {
console.debug(`updateWidget prevented on ${widget.getProp('id')} (widget not mounted yet)`)
return
}
var reuseChildren = options.reuseChildren !== false && widget instanceof Panel
var children = undefined,

View file

@ -104,6 +104,7 @@ var Parser = class Parser {
parentNode.appendChild(widget.container)
widget.mounted = true
// Editor needs to get the container object
return widget

View file

@ -148,6 +148,7 @@ class Widget extends EventEmitter {
this.children = []
this.reCreateOptions = options.reCreateOptions
this.removed = false
this.mounted = false
this.createPropsCache()

View file

@ -62,6 +62,7 @@ class Panel extends Container() {
for (let i = 0; i < this.children.length; i++) {
if (this.children[i]) {
this.wrapper.appendChild(this.children[i].container)
this.children[i].mounted = true
this.children[i].parent = this
this.children[i].parentNode = this.wrapper
} else {
@ -98,6 +99,7 @@ class Panel extends Container() {
for (let i = 0; i < this.children.length; i++) {
if (this.children[i]) {
this.widget.appendChild(this.children[i].container)
this.children[i].mounted = true
this.children[i].parent = this
this.children[i].parentNode = this.widget
} else {