fix: VC-Filter组件的适配问题

This commit is contained in:
林熠 2020-07-22 13:02:56 +08:00
parent 20fcfe6b29
commit 1f581b81f6
2 changed files with 43 additions and 6 deletions

View File

@ -132,6 +132,7 @@ export class NodeChildren {
}
this.emitter.emit('change');
this.reportModified(node, this.owner, { type: 'insert' });
// check condition group
if (node.conditionGroup) {
@ -288,24 +289,48 @@ export class NodeChildren {
return;
}
this.purged = true;
this.children.forEach(child => child.purge());
this.children.forEach((child) => child.purge());
}
get [Symbol.toStringTag]() {
// 保证向前兼容性
return "Array";
return 'Array';
}
/**
* @deprecated
* vision体系存量api
*/
getChildrenArray() {
return this.children;
}
private reportModified(node: Node, owner: Node, options = {}) {
if (!node) { return; }
if (node.isRoot()) { return; }
if (!node) {
return;
}
if (node.isRoot()) {
return;
}
const callbacks = owner.componentMeta.getMetadata().experimental?.callbacks;
if (callbacks?.onSubtreeModified) {
callbacks?.onSubtreeModified.call(node, owner, options);
try {
callbacks?.onSubtreeModified.call(node, owner, options);
} catch (e) {
console.error('error when excute experimental.callbacks.onNodeAdd', e);
}
}
if (callbacks?.onNodeAdd && options?.type === 'insert') {
try {
callbacks?.onNodeAdd.call(owner, node, owner);
} catch (e) {
console.error('error when excute experimental.callbacks.onNodeAdd', e);
}
}
if (owner.parent && !owner.parent.isRoot()) {
this.reportModified(node, owner.parent, options);
this.reportModified(node, owner.parent, options);
}
}
}

View File

@ -329,4 +329,16 @@ export class Props implements IPropParent {
setPropValue(path: string, value: any) {
this.getProp(path, true)!.setValue(value);
}
/**
* @deprecated
* vision体系
*/
getNode() {
const nodeForVision = this.owner;
nodeForVision.getChildren = () => {
return this.owner?.getChildren()?.getChildrenArray() || [];
};
return nodeForVision;
}
}