fix add child to group,not make root dirty

This commit is contained in:
pengfei.zhou
2019-07-24 12:48:30 +08:00
parent ac5dc091d5
commit f33c320b0c
7 changed files with 97 additions and 76 deletions

View File

@@ -140,7 +140,7 @@ export abstract class View implements Modeling {
}
this.__dirty_props__[propKey] = newV
if (this.parent instanceof Group) {
this.parent.onChildPropertyChanged(this, propKey, oldV, newV)
this.parent.onChildPropertyChanged(this)
}
}
@@ -220,6 +220,10 @@ export abstract class Group extends View {
const childrenModel = this.getDirtyChildrenModel()
childrenModel[parseInt(index)] = value.nativeViewModel
}
if (this.parent) {
this.parent.onChildPropertyChanged(this)
}
return Reflect.set(target, index, value)
}
})
@@ -246,9 +250,13 @@ export abstract class Group extends View {
return super.toModel()
}
onChildPropertyChanged(child: View, propKey: string, oldV: Model, newV: Model) {
onChildPropertyChanged(child: View) {
this.getDirtyChildrenModel()[this.children.indexOf(child)] = child.nativeViewModel
}
isDirty() {
return super.isDirty()
}
}
export class Stack extends Group {