widget: define isDynamicProp

This commit is contained in:
bordun 2018-11-01 10:55:39 +01:00
parent ab4f02de18
commit 0db5d36393
4 changed files with 11 additions and 5 deletions

View file

@ -27,7 +27,7 @@ function updateWidget(widget, options={}) {
if (
// if non dynamic props have changed, skip this and use rebuild routine
!propNames.some(n => !widget.constructor.dynamicProps.includes(n))
!propNames.some(n => !widget.isDynamicProp(n))
) {
var edited = widget.updateProps(options.changedProps, null) || widget

View file

@ -9,7 +9,7 @@ var widgetCategories = require('../widgets/').categories,
module.exports = function editField(editor, widget, propName, defaultValue){
let dynamic = widget.constructor.dynamicProps.includes(propName),
let dynamic = widget.isDynamicProp(propName),
disabled = widget.disabledProps.indexOf(propName) > -1,
error = widget.errors[propName]

View file

@ -604,6 +604,13 @@ class Widget extends EventEmitter {
return this.cachedProps[propName]
}
isDynamicProp(propName) {
return this.constructor.dynamicProps.indexOf(propName) !== -1
}
updateProps(propNames, widget, options, updatedProps = []) {
if (propNames.includes('value')) {
@ -623,8 +630,7 @@ class Widget extends EventEmitter {
if (!deepEqual(oldPropValue, propValue)) {
if (!this.constructor.dynamicProps.includes(propName)) {
if (!this.isDynamicProp(propName)) {
reCreate = true

View file

@ -207,7 +207,7 @@ class Clone extends Container {
diff.patch(widget.props, patch)
if (changedProps.some(x => !widget.constructor.dynamicProps.includes(x))) {
if (changedProps.some(x => !widget.isDynamicProp(x))) {
clone.reCreateWidget({reuseChildren: false})
this.updateContainer(false)